<?php
// +-------------------------------
// | 中润报表系统
// +-------------------------------
// | author: zw
// +-------------------------------

namespace app\adminapi\controller\report;

use app\adminapi\controller\BaseAdminController;
use think\facade\Db;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Fill;
use app\common\cache\ExportCache;

/**
 * 报表审核控制器
 * Class CheckController
 * @package app\adminapi\controller\report
 */
class CheckController extends BaseAdminController
{
    public $notNeedLogin = ['exportExcel'];
    public $errorMsg = '';
    /**
     * @notes 报表审核通过
     * @return \think\response\Json
     * @author zw
     * @date 2023/2/1 13:24
     */
    public function index()
    {
        // 接受所有参数
        $param = input('param.');
        // 如果没有传递date，就直接审核当天。如果传递了date就是补审
        $date = !empty($param['date'])?$param['date']:date('Y-m-d',strtotime('-1 day'));

        $is = Db::name('dispatch')->where('date',$date)->find();
        if(empty($is)){
            return $this->fail('审核之前请先保存当班调度');
        }

        // 修改参数
        $data = [
            'cid'=>$param['cid'],
            'cname'=>$param['cname'],
            'check_time'=>date('Y-m-d H:i:s'),
            'status'=>2
        ];

        try {
            Db::startTrans();
            $iscp = Db::name('ylmglqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('原料煤管理情况未提交数据');
            }
            $res = Db::name('ylmglqk')->where('date',$date)->update($data);
            
            $iscp = Db::name('pmzbjjtzlqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('配煤指标及焦炭质量情况未提交数据');
            }
            $res = Db::name('pmzbjjtzlqk')->where('date',$date)->update($data);
            
            $iscp = Db::name('cpxsjhglyljcqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('产品销售及化工类原料进出厂情况未提交数据');
            }
            Db::name('cpxsjhglyljcqk')->where('date',$date)->update($data);
            Db::name('sqlserver')->where('date',$date)->update($data);
            
            $iscp = Db::name('jlscjgykzqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('焦炉生产及工艺控制情况未提交数据');
            }
            $res = Db::name('jlscjgykzqk')->where('date',$date)->update($data);
            
            $iscp = Db::name('gxlscjgykzqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('干熄炉生产及工艺控制情况未提交数据');
            }
            $res = Db::name('gxlscjgykzqk')->where('date',$date)->update($data);

            $iscp = Db::name('jhscjgykzqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('净化生产及工艺控制情况未提交数据');
            }
            $res = Db::name('jhscjgykzqk')->where('date',$date)->update($data);
            
            $iscp = Db::name('dlscqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('动力生产情况未提交数据');
            }
            $res = Db::name('dlscqk')->where('date',$date)->update($data);
            
            $iscp = Db::name('jcscqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('甲醇生产情况未提交数据');
            }
            $res = Db::name('jcscqk')->where('date',$date)->update($data);
            
            $iscp = Db::name('jbscqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('精苯生产情况未提交数据');
            }
            $res = Db::name('jbscqk')->where('date',$date)->update($data);
            
            $iscp = Db::name('yqjzhtqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('园区介质互通情况未提交数据');
            }
            $res = Db::name('yqjzhtqk')->where('date',$date)->update($data);
            
            $iscp = Db::name('hbzb')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('水质指标分析未提交数据');
            }
            $res = Db::name('hbzb')->where('date',$date)->update($data);
            
            $iscp = Db::name('rscfx')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('日生产分析未提交数据');
            }
            $res = Db::name('rscfx')->where('date',$date)->update($data);
            
            $iscp = Db::name('rgcfx')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('日工程分析未提交数据');
            }
            $res = Db::name('rgcfx')->where('date',$date)->update($data);
            
            // 提交事务
            Db::commit();
            if($data['status']==3){
                return $this->success('驳回成功', [], 1, 1);
            }
            return $this->success('审核成功', [], 1, 1);
        } catch (\Exception $e) {
            // 回滚事务
            Db::rollback();
            return $this->fail('审核失败'.json_encode($e));
        }
        
        
    }


    /**
     * @notes 报表审核驳回
     * @return \think\response\Json
     * @author zw
     * @date 2023/2/1 13:24
     */
    public function bohui()
    {
        // 接受所有参数
        $param = input('param.');
        // 如果没有传递date，就直接审核当天。如果传递了date就是补审
        $date = !empty($param['date'])?$param['date']:date('Y-m-d',strtotime('-1 day'));

        $is = Db::name('dispatch')->where('date',$date)->find();
        if(empty($is)){
            return $this->fail('审核之前请先保存当班调度');
        }

        // 修改参数
        $data = [
            'cid'=>$param['cid'],
            'cname'=>$param['cname'],
            'check_time'=>date('Y-m-d H:i:s'),
            'status'=>3
        ];

        try {
            Db::startTrans();
            $iscp = Db::name('ylmglqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('原料煤管理情况未提交数据');
            }
            $res = Db::name('ylmglqk')->where('date',$date)->update($data);
            
            $iscp = Db::name('pmzbjjtzlqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('配煤指标及焦炭质量情况未提交数据');
            }
            $res = Db::name('pmzbjjtzlqk')->where('date',$date)->update($data);
            
            $iscp = Db::name('cpxsjhglyljcqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('产品销售及化工类原料进出厂情况未提交数据');
            }
            Db::name('cpxsjhglyljcqk')->where('date',$date)->update($data);
            Db::name('sqlserver')->where('date',$date)->update($data);
            
            $iscp = Db::name('jlscjgykzqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('焦炉生产及工艺控制情况未提交数据');
            }
            $res = Db::name('jlscjgykzqk')->where('date',$date)->update($data);
            
            $iscp = Db::name('gxlscjgykzqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('干熄炉生产及工艺控制情况未提交数据');
            }
            $res = Db::name('gxlscjgykzqk')->where('date',$date)->update($data);

            $iscp = Db::name('jhscjgykzqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('净化生产及工艺控制情况未提交数据');
            }
            $res = Db::name('jhscjgykzqk')->where('date',$date)->update($data);
            
            $iscp = Db::name('dlscqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('动力生产情况未提交数据');
            }
            $res = Db::name('dlscqk')->where('date',$date)->update($data);
            
            $iscp = Db::name('jcscqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('甲醇生产情况未提交数据');
            }
            $res = Db::name('jcscqk')->where('date',$date)->update($data);
            
            $iscp = Db::name('jbscqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('精苯生产情况未提交数据');
            }
            $res = Db::name('jbscqk')->where('date',$date)->update($data);
            
            $iscp = Db::name('yqjzhtqk')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('园区介质互通情况未提交数据');
            }
            $res = Db::name('yqjzhtqk')->where('date',$date)->update($data);
            
            $iscp = Db::name('hbzb')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('水质指标分析未提交数据');
            }
            $res = Db::name('hbzb')->where('date',$date)->update($data);
            
            $iscp = Db::name('rscfx')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('日生产分析未提交数据');
            }
            $res = Db::name('rscfx')->where('date',$date)->update($data);
            
            $iscp = Db::name('rgcfx')->where('date',$date)->find();
            if(empty($iscp)){
                return $this->fail('日工程分析未提交数据');
            }
            $res = Db::name('rgcfx')->where('date',$date)->update($data);
            
            // 提交事务
            Db::commit();
            if($data['status']==3){
                return $this->success('驳回成功', [], 1, 1);
            }
            return $this->success('审核成功', [], 1, 1);
        } catch (\Exception $e) {
            // 回滚事务
            Db::rollback();
            return $this->fail('审核失败'.json_encode($e));
        }
        
        
    }


    /**
     * @notes  获取报表未审核条数
     * @return \think\response\Json
     * @author zw
     * @date 2023/2/1 13:24
     */
    public function getNocheck()
    {
        $res = Db::query("SELECT * FROM `la_ylmglqk` where status!=2 group by date");
        return $this->data(["count"=>count($res)]);
    }
    
    /**
     * @notes 库存审核通过
     * @return \think\response\Json
     * @author zw
     * @date 2023/2/1 13:24
     */
    public function checkStock()
    {
        // 接受所有参数
        $param = input('param.');
        // 如果没有传递date，就直接审核当天。如果传递了date就是补审
        $date = !empty($param['date'])?$param['date']:date('Y-m-d',strtotime('-1 day'));

        // 修改参数
        $data = [
            'cid'=>$param['cid'],
            'cname'=>$param['cname'],
            'check_time'=>date('Y-m-d H:i:s'),
            'status'=>2
        ];
        $iscp = Db::name('stock')->where('date',$date)->find();
        if(empty($iscp)){
            return $this->fail('库存未提交数据');
        }
        $res = Db::name('stock')->where('date',$date)->update($data);

        if($res){
            if($data['status']==3){
                return $this->success('驳回成功', [], 1, 1);
            }
            return $this->success('审核成功', [], 1, 1);
        }
        return $this->fail('审核失败');
    }

    /**
     * @notes 库存审核驳回
     * @return \think\response\Json
     * @author zw
     * @date 2023/2/1 13:24
     */
    public function bohuiStock()
    {
        // 接受所有参数
        $param = input('param.');
        // 如果没有传递date，就直接审核当天。如果传递了date就是补审
        $date = !empty($param['date'])?$param['date']:date('Y-m-d',strtotime('-1 day'));

        // 修改参数
        $data = [
            'cid'=>$param['cid'],
            'cname'=>$param['cname'],
            'check_time'=>date('Y-m-d H:i:s'),
            'status'=>3
        ];
        $iscp = Db::name('stock')->where('date',$date)->find();
        if(empty($iscp)){
            return $this->fail('库存未提交数据');
        }
        $res = Db::name('stock')->where('date',$date)->update($data);

        if($res){
            if($data['status']==3){
                return $this->success('驳回成功', [], 1, 1);
            }
            return $this->success('审核成功', [], 1, 1);
        }
        return $this->fail('审核失败');
    }

    /**
     * @notes  获取库存未审核条数
     * @return \think\response\Json
     * @author zw
     * @date 2023/2/1 13:24
     */
    public function getStockNocheck()
    {
        $res = Db::query("SELECT * FROM `la_stock` where status!=2 group by date");
        return $this->data(["count"=>count($res)]);
    }

    /**
     * @notes  当班调度获取
     * @return \think\response\Json
     * @author zw
     * @date 2023/2/1 13:24
     */
    public function getDispatch()
    {
        // 接受所有参数
        $data = input('param.');
        $date = !empty($data['date'])?$data['date']:date('Y-m-d',strtotime('-1 day'));
        $is = Db::name('dispatch')->where('date',$date)->find();
        return $this->data($is?:['name'=>'d']);
    }

    /**
     * @notes 保存当班调度
     * @return \think\response\Json
     * @author zw
     * @date 2023/2/1 13:24
     */
    public function dispatchSave()
    {
        // 接受所有参数
        $param = input('param.');
        // 如果没有传递date，就直接审核当天。如果传递了date就是补审
        $date = !empty($param['date'])?$param['date']:date('Y-m-d',strtotime('-1 day'));
    // var_dump($param);die;
        // 修改参数
        $data = [
            'dbbai1'=>$param['dbbai1'],
            'dbbai2'=>$param['dbbai2'],
            'dbye1'=>!empty($param['dbye1'])?$param['dbye1']:'',
            'dbye2'=>!empty($param['dbye2'])?$param['dbye2']:'',
            'date'=>$date,
            'update_time'=>date('Y-m-d H:i:s'),
        ];
        // var_dump($data);die;
        $is = Db::name('dispatch')->where('date',$date)->find();
        if(!empty($is)){
            $res = Db::name('dispatch')->where('date',$date)->update($data);
        }else{
            $res = Db::name('dispatch')->insert($data);
        }
        
        if($res){
            return $this->success('保存成功', [], 1, 1);
        }
        return $this->fail('保存失败');
    }
    
    /**
     * @notes excel报表数据导出
     * @return \think\response\Json
     * @author zw
     * @date 2023/2/1 13:24
     */
    public function exportExcel(){
        $data = input('param.');
        $date = !empty($data['date'])?$data['date']:date('Y-m-d',strtotime('-1 day'));
        $where = [
            "date"=>$date,
            "status"=>2
        ];
        
        $spreadsheet = new Spreadsheet();
        // 创建sheet
        $sheet = $spreadsheet->getActiveSheet();
        // 全局样式
        $spreadsheet->getDefaultStyle()->getFont()->setName('宋体'); // 字体
        $spreadsheet->getDefaultStyle()->getFont()->setSize(13); // 字体大小
        $zmarr = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V'];
        foreach ($zmarr as $value) {
            $spreadsheet->getActiveSheet()->getColumnDimension($value)->setWidth(10);
        }
        //默认水平居中
        $spreadsheet->getDefaultStyle()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
        //默认垂直居中
        $spreadsheet->getDefaultStyle()->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
        // 自动换行
        $spreadsheet->getDefaultStyle()->getAlignment()->setWrapText(true);

        $border = [
            'borders' => [
                'outline' => [//外边框
                    'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
                ],
                'inside' =>[ //内边框
                    'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
                ]
            ],
         ];
        $spreadsheet->getActiveSheet(1)->getStyle('A1:V436')->applyFromArray($border);

        // 开始编写表格
        // 第一行
        $sheet->mergeCells('A1:T1');
        $sheet->setCellValue('A1','唐山中润煤化工有限公司生产日报表');
        $sheet->getCell('A1')->getStyle()->getFont()->setSize(22);
        $sheet->getCell("A1")->getStyle()->getFont()->setBold(true);   
        $sheet->mergeCells('U1:V1');
        $sheet->setCellValue('U1','当班调度');
        $spreadsheet->getActiveSheet(1)->getStyle('U1:V4')->getFont()->setBold(true);
        // 第二行
        $sheet->mergeCells('A2:T2');
        $sheet->setCellValue('A2','日期：'.$date);
        $sheet->getCell('A2')->getStyle()->getFont()->setSize(16);
        $sheet->getCell('A2')->getStyle()->getFont()->setBold(true);
        $sheet->setCellValue('U2','白班');
        $sheet->setCellValue('V2','夜班');
        
        // 第三行
        $sheet->mergeCells('A3:B4');
        // $sheet->setCellValue('A3','点击直达');
        $sheet->getCell("A3")->getStyle()->getFont()->setBold(true);
        $sheet->getCell("A3")->getStyle()->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');

        $sheet->mergeCells('C3:E3');
        // $sheet->setCellValue('C3','=HYPERLINK("#A30","01、原料煤管理情况")');
        $sheet->setCellValue('C3','01、原料煤管理情况');
        $sheet->mergeCells('F3:H3');
        // $sheet->setCellValue('F3','=HYPERLINK("#A59","02、配煤指标及焦炭质量情况")');
        $sheet->setCellValue('F3','02、配煤指标及焦炭质量情况');
        $sheet->mergeCells('I3:K3');
        // $sheet->setCellValue('I3','=HYPERLINK("#A84","03、产品销售及化工类原料进厂情况")');
        $sheet->setCellValue('I3','03、产品销售及化工类原料进厂情况');
        $sheet->mergeCells('L3:N3');
        // $sheet->setCellValue('L3','=HYPERLINK("#A95","04、焦炉生产及工艺控制情况")');
        $sheet->setCellValue('L3','04、焦炉生产及工艺控制情况');
        $sheet->mergeCells('O3:Q3');
        // $sheet->setCellValue('O3','=HYPERLINK("#A104","05、干熄炉生产及工艺控制情况")');
        $sheet->setCellValue('O3','05、干熄炉生产及工艺控制情况');
        $sheet->mergeCells('R3:T3');
        // $sheet->setCellValue('R3','=HYPERLINK("#A127","06、净化生产及工艺控制情况")');
        $sheet->setCellValue('R3','06、净化生产及工艺控制情况');
        $spreadsheet->getActiveSheet(1)->getStyle('C3:T4')->getFont()->setSize(10);

        $dispatch = Db::name('dispatch')->where('date',$date)->find();
        $sheet->setCellValue('U3',$dispatch['dbbai1']);
        $sheet->setCellValue('V3',$dispatch['dbye1']);
        $spreadsheet->getActiveSheet(1)->getStyle('U3:V4')->getFont()->setSize(11);
         
        // 第四行
        $sheet->mergeCells('C4:E4');
        // $sheet->setCellValue('C4','=HYPERLINK("#A145","07、动力生产情况")');
        $sheet->setCellValue('C4','07、动力生产情况');
        $sheet->mergeCells('F4:H4');
        // $sheet->setCellValue('F4','=HYPERLINK("#A159","08、甲醇生产情况")');
        $sheet->setCellValue('F4','08、甲醇生产情况');
        $sheet->mergeCells('I4:K4');
        // $sheet->setCellValue('I4','=HYPERLINK("#A175","09、精苯生产情况")');
        $sheet->setCellValue('I4','09、精苯生产情况');
        $sheet->mergeCells('L4:N4');
        // $sheet->setCellValue('L4','=HYPERLINK("#A193","10、园区介质互通情况")');
        $sheet->setCellValue('L4','10、园区介质互通情况');
        $sheet->mergeCells('O4:Q4');
        // $sheet->setCellValue('O4','=HYPERLINK("#A211","11、水质指标分析")');
        $sheet->setCellValue('O4','11、水质指标分析');
        $sheet->mergeCells('R4:T4');
        // $sheet->setCellValue('R4','=HYPERLINK("#A250","12、日生产分析")');
        $sheet->setCellValue('R4','12、日生产分析');

        $sheet->setCellValue('U4',$dispatch['dbbai2']);
        $sheet->setCellValue('V4',$dispatch['dbye2']);

        //原料煤管理情况 报表
        $sheet = $this->ylmglqk($sheet,$where);
        if($this->errorMsg!=''){
            return $this->fail($this->errorMsg);
        }
        
        //配煤指标及焦炭质量情况 报表
        $sheet = $this->pmzbjjtzlqk($sheet,$where);
        if($this->errorMsg!=''){
            return $this->fail($this->errorMsg);
        }
        
        //产品销售及化工类原料进出厂情况 报表
        $sheet = $this->cpxsjhglyljcqk($sheet,$where);
        if($this->errorMsg!=''){
            return $this->fail($this->errorMsg);
        }
        
        //焦炉生产及工艺控制情况 报表
        $sheet = $this->jlscjgykzqk($sheet,$where);
        if($this->errorMsg!=''){
            return $this->fail($this->errorMsg);
        }

        //干熄炉生产及工艺控制情况 报表
        $sheet = $this->gxlscjgykzqk($sheet,$where);
        if($this->errorMsg!=''){
            return $this->fail($this->errorMsg);
        }

        //净化生产及工艺控制情况 报表
        $sheet = $this->jhscjgykzqk($sheet,$where);
        if($this->errorMsg!=''){
            return $this->fail($this->errorMsg);
        }

        //动力生产情况 报表
        $sheet = $this->dlscqk($sheet,$where);
        if($this->errorMsg!=''){
            return $this->fail($this->errorMsg);
        }

        //甲醇生产情况 报表
        $sheet = $this->jcscqk($sheet,$where);
        if($this->errorMsg!=''){
            return $this->fail($this->errorMsg);
        }

        //精苯生产情况 报表
        $sheet = $this->jbscqk($sheet,$where);
        if($this->errorMsg!=''){
            return $this->fail($this->errorMsg);
        }

        //园区介质互通情况 报表
        $sheet = $this->yqjzhtqk($sheet,$where);
        if($this->errorMsg!=''){
            return $this->fail($this->errorMsg);
        }

        //水质指标分析 报表
        $sheet = $this->hbzb($sheet,$where);
        if($this->errorMsg!=''){
            return $this->fail($this->errorMsg);
        }

        //日生产分析 报表
        $sheet = $this->rscfx($sheet,$where);
        if($this->errorMsg!=''){
            return $this->fail($this->errorMsg);
        }

        //日工程分析 报表
        $sheet = $this->rgcfx($sheet,$where);
        if($this->errorMsg!=''){
            return $this->fail($this->errorMsg);
        }

        // 样式设置
        $sheet->getDefaultColumnDimension()->setWidth(12);
        // 设置下载与后缀
        header("Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        ob_end_clean();//清楚缓存区
        $filename = $date.'生产日报表';
        // 激活浏览器窗口
        header("Content-Disposition:attachment;filename=$filename.xlsx");
        //缓存控制
        header("Cache-Control:max-age=0");
        // 调用方法执行下载
        $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
        //创建excel文件
        $exportCache = new ExportCache();
        $src = $exportCache->getSrc();

        if (!file_exists($src)) {
            mkdir($src, 0775, true);
        }
        $writer->save($src . $filename.'.xlsx');
        //设置本地excel缓存并返回下载地址
        $vars = ['file' => $exportCache->setFile($filename.'.xlsx')];
        return $this->success('', ['path'=>(string)(url('adminapi/download/export', $vars, true, true))], 1, 1);
    }
    
    //原料煤管理情况 报表
    public function ylmglqk($sheet,$where){
        $ylmglqkData = Db::name('ylmglqk')->where($where)->select()->toArray();
        if(empty($ylmglqkData)){
            $this->errorMsg = '原料煤管理情况中没有找到已审核数据';
            return $sheet;
        }
        // 第五行   
        $sheet->mergeCells('A5:V5');
        $sheet->setCellValue('A5','原料煤管理情况');
        $sheet->getCell('A5')->getStyle()->getFont()->setSize(18);
        $sheet->getCell("A5")->getStyle()->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A5:V29')->getFont()->setBold(true);

        // 第6行   
        $sheet->mergeCells('A6:A26');
        $sheet->setCellValue('A6','煤场贮煤情况');
        $sheet->getCell("A6")->getStyle()->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');

        $sheet->mergeCells('B6:B7');
        $sheet->setCellValue('B6','序号');
        $sheet->mergeCells('C6:E6');
        $sheet->setCellValue('C6','A区');
        $sheet->setCellValue('C7','煤种');
        $sheet->setCellValue('D7','名称');
        $sheet->setCellValue('E7','数量');
        $sheet->mergeCells('F6:H6');
        $sheet->setCellValue('F6','B区');
        $sheet->setCellValue('F7','煤种');
        $sheet->setCellValue('G7','名称');
        $sheet->setCellValue('H7','数量');
        $sheet->mergeCells('I6:K6');
        $sheet->setCellValue('I6','C区');
        $sheet->setCellValue('I7','煤种');
        $sheet->setCellValue('J7','名称');
        $sheet->setCellValue('K7','数量');
        $sheet->mergeCells('L6:N6');
        $sheet->setCellValue('L6','D区');
        $sheet->setCellValue('L7','煤种');
        $sheet->setCellValue('M7','名称');
        $sheet->setCellValue('N7','数量');

        $sheet->mergeCells('O6:O26');
        $sheet->setCellValue('O6','每日进厂煤统计');
        $sheet->mergeCells('P6:P7');
        $sheet->setCellValue('P6','序号');
        $sheet->mergeCells('Q6:Q7');
        $sheet->setCellValue('Q6','运输方式');
        $sheet->mergeCells('R6:R7');
        $sheet->setCellValue('R6','煤种名称');
        $sheet->mergeCells('S6:S7');
        $sheet->setCellValue('S6','进厂车数');
        $sheet->mergeCells('T6:T7');
        $sheet->setCellValue('T6','进厂总量（t）');
        $sheet->mergeCells('U6:U7');
        $sheet->setCellValue('U6','日累计（t）');
        $sheet->mergeCells('V6:V7');
        $sheet->setCellValue('V6','存储位置');
        
        $sheet->mergeCells('Q8:Q21');
        $sheet->setCellValue('Q8','汽运');
        $sheet->mergeCells('Q22:Q26');
        $sheet->setCellValue('Q22','火运');
        
        $sheet->mergeCells('U8:U21');
        $sheet->mergeCells('U22:U26');
        // 填入数据
        $i = 8;
        $j = 1;
        $content = '';
        foreach ($ylmglqkData as $key => $value) {
            $sheet->setCellValue('B'.$i,($key+1));
            $sheet->setCellValue('C'.$i,$value['amz']);
            $sheet->setCellValue('D'.$i,$value['amc']);
            if(!empty($value['asl']) && $value['asl']!=0){
                $sheet->setCellValue('E'.$i,$value['asl']);
            }
            $sheet->setCellValue('F'.$i,$value['bmz']);
            $sheet->setCellValue('G'.$i,$value['bmc']);
            if(!empty($value['bsl']) && $value['bsl']!=0){
                $sheet->setCellValue('H'.$i,$value['bsl']);
            }
            $sheet->setCellValue('I'.$i,$value['cmz']);
            $sheet->setCellValue('J'.$i,$value['cmc']);
            if(!empty($value['csl']) && $value['csl']!=0){
                $sheet->setCellValue('K'.$i,$value['csl']);
            }
            $sheet->setCellValue('L'.$i,$value['dmz']);
            $sheet->setCellValue('M'.$i,$value['dmc']);
            if(!empty($value['dsl']) && $value['dsl']!=0){
                $sheet->setCellValue('N'.$i,$value['dsl']);
            }
            
            $sheet->setCellValue('P'.$i,$j);
            
            $sheet->setCellValue('R'.$i,$value['mzmc']);
            if(!empty($value['jccs']) && $value['jccs']!=0) $sheet->setCellValue('S'.$i,$value['jccs']);
            if(!empty($value['jczl']) && $value['jczl']!=0) $sheet->setCellValue('T'.$i,$value['jczl']);
            $sheet->setCellValue('V'.$i,$value['ccwz']);

            $i++;
            $j++;
            if($j>14){
                $j=1;
            }else{
            }

            $jnmcl = $value['jnmcl'];
            $content = $value['content'];
        }
        // 汽运和火运的值
        $sheet->setCellValue('U8',"=SUM(T8:T21)");
        $sheet->setCellValue('U22',"=SUM(T22:T26)");

        $sheet->setCellValue('B26','合计');
        $sheet->setCellValue('E26',"=SUM(E8:E25)");
        $sheet->setCellValue('H26',"=SUM(H8:H25)");
        $sheet->setCellValue('K26',"=SUM(K8:K25)");
        $sheet->setCellValue('N26',"=SUM(N8:N25)");
        
        $sheet->mergeCells('A27:D27');
        $sheet->setCellValue('A27','库存总量（t）');
        $sheet->mergeCells('F27:J27');
        $sheet->setCellValue('F27','煤场存量（t）');
        $sheet->mergeCells('L27:M27');
        $sheet->setCellValue('L27','局内煤存量（t）');
        $sheet->mergeCells('O27:Q27');
        $sheet->setCellValue('O27','日进厂煤合计（t）');
        $sheet->mergeCells('R27:V27');

        // 库存总量  先写着  后面需要加上配煤表的 槽煤存量
        $sheet->setCellValue('E27',"=K27+L51");
        // 煤场存量（t）
        $sheet->setCellValue('K27',"=E26+H26+K26+N26");
        // 局内煤存量（t）
        $sheet->setCellValue('N27',sprintf("%01.2f", $jnmcl));
        // 日进厂煤合计（t）
        $sheet->setCellValue('R27',"=U22+U8");

        $sheet->mergeCells('A28:V29');
        // 备注
        $sheet->setCellValue('A28',$content);
        $styleArray2 = [
            'alignment' => [
                'horizontal' => Alignment::HORIZONTAL_LEFT,
                'vertical'=>Alignment::VERTICAL_TOP
            ],
        ];
        $sheet->getStyle('A28')->applyFromArray($styleArray2);
        
        $sheet->getCell("E26")->getStyle()->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getCell("H26")->getStyle()->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getCell("K26")->getStyle()->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getCell("N26")->getStyle()->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A27:M27')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('O27:V27')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');

        return $sheet;
    }

    //配煤指标及焦炭质量情况 报表
    public function pmzbjjtzlqk($sheet,$where){
        $pmzbjjtzlqkData = Db::name('pmzbjjtzlqk')->where($where)->select()->toArray();
        if(empty($pmzbjjtzlqkData)){
            $this->errorMsg = '配煤指标及焦炭质量情况中没有找到已审核数据';
            return $sheet;
        }
        // 第五行   
        $sheet->mergeCells('A30:V30');
        $sheet->setCellValue('A30','配煤指标及焦炭质量情况');
        $sheet->getCell('A30')->getStyle()->getFont()->setSize(18);
        $sheet->getCell("A30")->getStyle()->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A30:V58')->getFont()->setBold(true);

        // 第6行   
        $sheet->mergeCells('A31:A54');
        $sheet->setCellValue('A31','配煤管理');
        $sheet->getCell("A31")->getStyle()->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');

        $sheet->setCellValue('C31','煤种名称');
        $sheet->setCellValue('D31','1#煤塔配比原配比');
        $sheet->setCellValue('E31','2#煤塔配比原配比');
        $sheet->setCellValue('F31','1#煤塔配比变更后');
        $sheet->setCellValue('G31','2#煤塔配变更后');
        $sheet->setCellValue('H31','日耗量');
        $sheet->setCellValue('I31','水份');
        $sheet->setCellValue('L31','存量');

        
        $sheet->mergeCells('O33:P33');
        $sheet->mergeCells('Q33:R33');
        $sheet->mergeCells('O34:P34');
        $sheet->mergeCells('Q34:R34');
        $sheet->mergeCells('O35:P35');
        $sheet->mergeCells('Q35:R35');
        $sheet->mergeCells('O36:P36');
        $sheet->mergeCells('Q36:R36');
        $sheet->mergeCells('O37:P37');
        $sheet->mergeCells('Q37:R37');
        $sheet->mergeCells('O38:P38');
        $sheet->mergeCells('Q38:R38');
        $sheet->mergeCells('O39:P39');
        $sheet->mergeCells('Q39:R39');
        $sheet->mergeCells('O40:P40');
        $sheet->mergeCells('Q40:R40');
        $sheet->mergeCells('O42:P42');
        $sheet->mergeCells('Q42:R42');
        $sheet->mergeCells('O43:P43');
        $sheet->mergeCells('Q43:R43');
        $sheet->mergeCells('S43:V43');
        $sheet->mergeCells('O44:P44');
        $sheet->mergeCells('Q44:R44');
        $sheet->mergeCells('S44:V44');
        $sheet->mergeCells('O45:P45');
        $sheet->mergeCells('Q45:R45');
        $sheet->mergeCells('S45:V45');
        $sheet->mergeCells('O46:P46');
        $sheet->mergeCells('Q46:R46');
        $sheet->mergeCells('S46:V46');
        $sheet->mergeCells('O47:P47');
        $sheet->mergeCells('Q47:R47');
        $sheet->mergeCells('S47:V47');

        // 填入数据
        $k = 32;
        $sumavgld = 0;
        foreach ($pmzbjjtzlqkData as $key => $value) {
            $sheet->setCellValue('B'.$k,$key+1);
            $sheet->setCellValue('C'.$k,$value['mzmc']);

            if(!empty($value['onemtpb']) && $value['onemtpb']!=0){
                $sheet->setCellValue('D'.$k,$value['onemtpb']);
            }
            if(!empty($value['twomtpb']) && $value['twomtpb']!=0){
                $sheet->setCellValue('E'.$k,$value['twomtpb']);
            }
            if(!empty($value['onemtpbu']) && $value['onemtpbu']!=0){
                $sheet->setCellValue('F'.$k,$value['onemtpbu']);
            }
            if(!empty($value['twomtpbu']) && $value['twomtpbu']!=0){
                $sheet->setCellValue('G'.$k,$value['twomtpbu']);
            }
            if(!empty($value['rhl']) && $value['rhl']!=0){
                $sheet->setCellValue('H'.$k,$value['rhl']);
            }
            if(!empty($value['sf']) && $value['sf']!=0){
                $sheet->setCellValue('I'.$k,$value['sf']);
            }
            if(!empty($value['cl']) && $value['cl']!=0){
                $sheet->setCellValue('L'.$k,$value['cl']);
            }
            if($key==1){
                $sheet->setCellValue('O33',$value['baishui']?$value['baishui']:'');
                $sheet->setCellValue('Q33',$value['yeshui']?$value['yeshui']:'');
            }
            if($key==2){
                $sheet->setCellValue('O34',$value['baihui']?$value['baihui']:'');
                $sheet->setCellValue('Q34',$value['yehui']?$value['yehui']:'');
            }
            if($key==3){
                $sheet->setCellValue('O35',$value['baihuifa']?$value['baihuifa']:'');
                $sheet->setCellValue('Q35',$value['yehuifa']?$value['yehuifa']:'');
            }
            if($key==4){
                $sheet->setCellValue('O36',$value['bailiu']?$value['bailiu']:'');
                $sheet->setCellValue('Q36',$value['yeliu']?$value['yeliu']:'');
            }
            if($key==5){
                $sheet->setCellValue('O37',$value['baim40']?$value['baim40']:'');
                $sheet->setCellValue('Q37',$value['yem40']?$value['yem40']:'');
            }
            if($key==6){
                $sheet->setCellValue('O38',$value['baim10']?$value['baim10']:'');
                $sheet->setCellValue('Q38',$value['yem10']?$value['yem10']:'');
            }
            if($key==7){
                $sheet->setCellValue('O39',$value['baifyx']?$value['baifyx']:'');
                $sheet->setCellValue('Q39',$value['yefyx']?$value['yefyx']:'');
            }
            if($key==8){
                $sheet->setCellValue('O40',$value['baifyqd']?$value['baifyqd']:'');
                $sheet->setCellValue('Q40',$value['yefyqd']?$value['yefyqd']:'');
            }
            if($key==10){
                $sheet->setCellValue('O42',$value['bg80']?$value['bg80']:'');
                $sheet->setCellValue('Q42',$value['ye80']?$value['ye80']:'');
                $avgld = ($value['bg80']+$value['ye80'])/2*0.9; //平均粒度
                $sumavgld += $avgld;
                $sheet->setCellValue('S42',$avgld?$avgld:'');
            }
            if($key==11){
                $sheet->setCellValue('O43',$value['bg60']?$value['bg60']:'');
                $sheet->setCellValue('Q43',$value['ye60']?$value['ye60']:'');
                $avgld = ($value['bg60']+$value['ye60'])/2*0.7; //平均粒度
                $sumavgld += $avgld;
                $sheet->setCellValue('S43',$avgld?$avgld:'');
            }
            if($key==12){
                $sheet->setCellValue('O44',$value['bg40']?$value['bg40']:'');
                $sheet->setCellValue('Q44',$value['ye40']?$value['ye40']:'');
                $avgld = ($value['bg40']+$value['ye40'])/2*0.5; //平均粒度
                $sumavgld += $avgld;
                $sheet->setCellValue('S44',$avgld?$avgld:'');
            }
            if($key==13){
                $sheet->setCellValue('O45',$value['bg25']?$value['bg25']:'');
                $sheet->setCellValue('Q45',$value['ye25']?$value['ye25']:'');
                $avgld = ($value['bg25']+$value['ye25'])/2*0.325; //平均粒度
                $sumavgld += $avgld;
                $sheet->setCellValue('S45',$avgld?$avgld:'');
            }
            if($key==14){
                $sheet->setCellValue('O46',$value['bg0']?$value['bg0']:'');
                $sheet->setCellValue('Q46',$value['ye0']?$value['ye0']:'');
                $avgld = ($value['bg0']+$value['ye0'])/2*0.125; //平均粒度
                $sumavgld += $avgld;
                $sheet->setCellValue('S46',$avgld?$avgld:'');
            }
            if($key==15){
                $sheet->setCellValue('O47','');
                $sheet->setCellValue('Q47','');
                $sheet->setCellValue('S47',$sumavgld?$sumavgld:'');
            }
            
            $k++;
        }

        $sheet->getStyle('S42:V47')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        
        $sheet->setCellValue('B51','20');
        $sheet->setCellValue('B52','21');
        $sheet->setCellValue('B53','22');
        $sheet->setCellValue('B54','23');

        $sheet->mergeCells('I51:J51');
        $sheet->setCellValue('I51','解冻库耗煤气（万）');
        $sheet->getStyle('I51')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');

        $sheet->setCellValue('K51','槽煤存量');
        $sheet->setCellValue('L51',"=SUM(L32:L50)");

        $sheet->getStyle('L51')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        // 其他详情数据 直接取一条
        $info = [];
        if(!empty($pmzbjjtzlqkData)){
            $info = $pmzbjjtzlqkData[0];
        }
        
        $sheet->mergeCells('I52:J52');
        $sheet->setCellValue('I52',$info['jdkhmq']);
        $sheet->mergeCells('K52:L52');
        $sheet->setCellValue('K52','净化甲醇废液（m³）');
        $sheet->getStyle('K52')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->mergeCells('I53:J53');
        $sheet->setCellValue('I53','煤塔存量（t）');
        $sheet->setCellValue('I54',$info['mtcl1']);
        $sheet->setCellValue('J54',$info['mtcl2']);

        $sheet->setCellValue('K53','甲醇');
        $sheet->setCellValue('L53',$info['jiachun']);
        $sheet->setCellValue('K54','净化');
        $sheet->setCellValue('L54',$info['jinghua']);
        $sheet->setCellValue('K55','取煤');
        // 备注
        $sheet->setCellValue('M48',$info['content']);
        $styleArray2 = [
            'alignment' => [
                'horizontal' => Alignment::HORIZONTAL_LEFT,
                'vertical'=>Alignment::VERTICAL_TOP
            ],
        ];
        $sheet->getStyle('M48')->applyFromArray($styleArray2);

        $sheet->mergeCells('M31:M47');
        $sheet->setCellValue('M31','焦炭质量');
        $sheet->mergeCells('N31:N32');
        $sheet->setCellValue('N31','指标');
        $sheet->mergeCells('O31:R31');
        $sheet->setCellValue('O31','干熄');
        $sheet->mergeCells('O32:P32');
        $sheet->setCellValue('O32','白班');
        $sheet->mergeCells('Q32:R32');
        $sheet->setCellValue('Q32','夜班');
        

        $sheet->mergeCells('S31:T31');
        $sheet->mergeCells('U31:V31');
        
        // 后面空白
        for($i=0;$i<9;$i++){
            $num = 32+$i;
            $sheet->mergeCells('S'.$num.':T'.$num);
            $sheet->mergeCells('U'.$num.':V'.$num);
        }
        

        $sheet->getStyle('B31:N31')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');

        $sheet->setCellValue('N33','水分');
        $sheet->setCellValue('N34','灰分');
        $sheet->setCellValue('N35','挥发分');
        $sheet->setCellValue('N36','硫分');
        $sheet->setCellValue('N37','M40');
        $sheet->setCellValue('N38','M10');
        $sheet->setCellValue('N39','反应性');
        $sheet->setCellValue('N40','反应后强度');
        $sheet->setCellValue('N41','粒度');
        $sheet->setCellValue('N42','＞80');
        $sheet->setCellValue('N43','80-60');
        $sheet->setCellValue('N44','60-40');
        $sheet->setCellValue('N45','40-25');
        $sheet->setCellValue('N46','＜25');

        $sheet->getStyle('N33:N47')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        
        $sheet->mergeCells('O41:P41');
        $sheet->setCellValue('O41','白班（干）');
        $sheet->mergeCells('Q41:R41');
        $sheet->setCellValue('Q41','夜班（干）');
        $sheet->mergeCells('S41:V41');
        $sheet->setCellValue('S41','平均粒度');
        // 后面空白
        for($i=0;$i<6;$i++){
            $num = 42+$i;
            $sheet->mergeCells('S'.$num.':V'.$num);
        }

        $sheet->mergeCells('M48:V58');

        
        $sheet->mergeCells('A55:B55');
        $sheet->setCellValue('A55','合计');
        $sheet->getStyle('A55')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');

        $sheet->setCellValue('D55',"=SUM(D32:D54)");
        $sheet->setCellValue('E55',"=SUM(E32:E54)");
        $sheet->setCellValue('F55',"=SUM(F32:F54)");
        $sheet->setCellValue('G55',"=SUM(G32:G54)");
        $sheet->setCellValue('H55',"=SUM(H32:H54)");
        $sheet->mergeCells('I55:J55');
        $sheet->setCellValue('I55',"=SUM(I54,J54)");
        $sheet->setCellValue('L55',$info['qumei']);
        $sheet->getStyle('D55:K55')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');

        $sheet->mergeCells('A56:B58');
        $sheet->setCellValue('A56','入炉煤指标');
        $sheet->getStyle('A56')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');

        $sheet->setCellValue('C57','白班');
        $sheet->setCellValue('C58','夜班');

        $sheet->setCellValue('G56','水分');
        $sheet->setCellValue('H56','灰分');
        $sheet->setCellValue('I56','挥发分');
        $sheet->setCellValue('J56','硫分');
        $sheet->setCellValue('K56','G');
        $sheet->setCellValue('L56','细度');
        
        $rlmzb = json_decode($info['rlmzb'],true);
        $sheet->setCellValue('G57',$rlmzb['bshuifen']);
        $sheet->setCellValue('G58',$rlmzb['yshuifen']);
        $sheet->setCellValue('H57',$rlmzb['bhuifen']);
        $sheet->setCellValue('H58',$rlmzb['yhuifen']);
        $sheet->setCellValue('I57',$rlmzb['bhuifafen']);
        $sheet->setCellValue('I58',$rlmzb['yhuifafen']);
        $sheet->setCellValue('J57',$rlmzb['bliufen']);
        $sheet->setCellValue('J58',$rlmzb['yliufen']);
        $sheet->setCellValue('K57',$rlmzb['bg']);
        $sheet->setCellValue('K58',$rlmzb['yg']);
        $sheet->setCellValue('L57',$rlmzb['bxidu']);
        $sheet->setCellValue('L58',$rlmzb['yxidu']);

        $sheet->mergeCells('A59:V59');
        return $sheet;
    }
    
    //产品销售及化工类原料进出厂情况 报表
    public function cpxsjhglyljcqk($sheet,$where){
        $cpxsjhglyljcqkData = Db::name('cpxsjhglyljcqk')->where($where)->select()->toArray();
        if(empty($cpxsjhglyljcqkData)){
            $this->errorMsg = '产品销售及化工类原料进出厂情况中没有找到已审核数据';
            return $sheet;
        }
        $sheet->mergeCells('A60:V60');
        $sheet->setCellValue('A60','产品销售及化工类原料进出厂情况');
        $sheet->getStyle('A60')->getFont()->setSize(18);
        $sheet->getStyle('A60:V83')->getFont()->setBold(true);
        $sheet->getStyle('A60:V62')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('B72:L73')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A75:L77')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('T65:T71')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        
        $sheet->mergeCells('A61:A75');
        $sheet->setCellValue('A61','焦炭产品销售');
        $sheet->mergeCells('B61:B62');
        $sheet->setCellValue('B61','用户名称');
        $sheet->mergeCells('C61:D61');
        $sheet->setCellValue('C61','干焦');
        $sheet->setCellValue('C62','日销');
        $sheet->setCellValue('D62','月累计');
        $sheet->mergeCells('E61:F61');
        $sheet->setCellValue('E61','焦丁');
        $sheet->setCellValue('E62','日销');
        $sheet->setCellValue('F62','月累计');
        $sheet->mergeCells('G61:H61');
        $sheet->setCellValue('G61','湿焦粉');
        $sheet->setCellValue('G62','日销');
        $sheet->setCellValue('H62','月累计');
        $sheet->mergeCells('I61:J61');
        $sheet->setCellValue('I61','干焦粉');
        $sheet->setCellValue('I62','日销');
        $sheet->setCellValue('J62','月累计');
        $sheet->mergeCells('K61:L61');
        $sheet->setCellValue('K61','焦末');
        $sheet->setCellValue('K62','日销');
        $sheet->setCellValue('L62','月累计');

        $sheet->mergeCells('B73:C75');
        $sheet->setCellValue('B73','库存');
        $sheet->mergeCells('D73:I73');
        $sheet->setCellValue('D73','65焦');
        $sheet->mergeCells('J73:L73');
        $sheet->setCellValue('J73','湿焦');
        $sheet->mergeCells('D74:F74');
        $sheet->setCellValue('D74','火运仓');
        $sheet->mergeCells('G74:I74');
        $sheet->setCellValue('G74','筒仓');
        $sheet->mergeCells('J74:L74');
        $sheet->mergeCells('D75:F75');
        $sheet->mergeCells('G75:I75');
        $sheet->setCellValue('J75','总计：');
        $sheet->mergeCells('K75:L75');
        $sheet->mergeCells('M81:V83');

        // 填入数据
        $a = 63;
        foreach ($cpxsjhglyljcqkData as $key => $value) {
            $sheet->setCellValue('B'.$a,$value['yhmc']);
            if(!empty($value['gjr']) && $value['gjr']!=0) $sheet->setCellValue('C'.$a,$value['gjr']);
            if(!empty($value['gjy']) && $value['gjy']!=0) $sheet->setCellValue('D'.$a,$value['gjy']);
            if(!empty($value['jdr']) && $value['jdr']!=0) $sheet->setCellValue('E'.$a,$value['jdr']);
            if(!empty($value['jdy']) && $value['jdy']!=0) $sheet->setCellValue('F'.$a,$value['jdy']);
            if(!empty($value['sjfr']) && $value['sjfr']!=0) $sheet->setCellValue('G'.$a,$value['sjfr']);
            if(!empty($value['sjfy']) && $value['sjfy']!=0) $sheet->setCellValue('H'.$a,$value['sjfy']);
            if(!empty($value['gjfr']) && $value['gjfr']!=0) $sheet->setCellValue('I'.$a,$value['gjfr']);
            if(!empty($value['gjfy']) && $value['gjfy']!=0) $sheet->setCellValue('J'.$a,$value['gjfy']);
            if(!empty($value['jmr']) && $value['jmr']!=0) $sheet->setCellValue('K'.$a,$value['jmr']);
            if(!empty($value['jmy']) && $value['jmy']!=0) $sheet->setCellValue('L'.$a,$value['jmy']);
            
            $sheet->setCellValue('B72','合计');
            if(!empty($value['gjrtotal']) && $value['gjrtotal']!=0) $sheet->setCellValue('C72',$value['gjrtotal']);
            if(!empty($value['gjytotal']) && $value['gjytotal']!=0) $sheet->setCellValue('D72',$value['gjytotal']);
            if(!empty($value['jdrtotal']) && $value['jdrtotal']!=0) $sheet->setCellValue('E72',$value['jdrtotal']);
            if(!empty($value['jdytotal']) && $value['jdytotal']!=0) $sheet->setCellValue('F72',$value['jdytotal']);
            if(!empty($value['sjfrtotal']) && $value['sjfrtotal']!=0) $sheet->setCellValue('G72',$value['sjfrtotal']);
            if(!empty($value['sjfytotal']) && $value['sjfytotal']!=0) $sheet->setCellValue('H72',$value['sjfytotal']);
            if(!empty($value['gjfrtotal']) && $value['gjfrtotal']!=0) $sheet->setCellValue('I72',$value['gjfrtotal']);
            if(!empty($value['gjfytotal']) && $value['gjfytotal']!=0) $sheet->setCellValue('J72',$value['gjfytotal']);
            if(!empty($value['jmrtotal']) && $value['jmrtotal']!=0) $sheet->setCellValue('K72',$value['jmrtotal']);
            if(!empty($value['jmytotal']) && $value['jmytotal']!=0) $sheet->setCellValue('L72',$value['jmytotal']);
            
            if(!empty($value['jiao65']) && $value['jiao65']!=0) $sheet->setCellValue('D75',$value['jiao65']);
            if(!empty($value['jiao63']) && $value['jiao63']!=0) $sheet->setCellValue('G75',$value['jiao63']);
            if(!empty($value['shijiao']) && $value['shijiao']!=0) $sheet->setCellValue('J74',$value['shijiao']);
            if(!empty($value['jiao65']) && !empty($value['jiao63'])) $sheet->setCellValue('K75',sprintf('%.2f',$value['jiao65']+$value['jiao63']));

            $sheet->setCellValue('M81',$value['content']);
            $a++;
        }
        
        $styleArray2 = [
            'alignment' => [
                'horizontal' => Alignment::HORIZONTAL_LEFT,
                'vertical'=>Alignment::VERTICAL_TOP
            ],
        ];
        $sheet->getStyle('M81')->applyFromArray($styleArray2);
        
        // 进厂
        $sheet->mergeCells('A76:A83');
        $sheet->setCellValue('A76','化工类原料进厂');
        $sheet->mergeCells('B76:B77');
        $sheet->setCellValue('B76','序号');
        $sheet->mergeCells('C76:D77');
        $sheet->setCellValue('C76','物料名称');
        $sheet->mergeCells('E76:F77');
        $sheet->setCellValue('E76','进料车数');
        $sheet->mergeCells('G76:H77');
        $sheet->setCellValue('G76','进料净重');
        $sheet->mergeCells('I76:J77');
        $sheet->setCellValue('I76','月累计进料');
        $sheet->mergeCells('K76:L77');
        $sheet->setCellValue('K76','库存');
        $b = 78;
        for ($i=0; $i < 6; $i++) { 
            $sheet->setCellValue('B'.($b+$i),($i+1));
            $sheet->mergeCells('C'.($b+$i).':D'.($b+$i));
            $sheet->mergeCells('E'.($b+$i).':F'.($b+$i));
            $sheet->mergeCells('G'.($b+$i).':H'.($b+$i));
            $sheet->mergeCells('I'.($b+$i).':J'.($b+$i));
            $sheet->mergeCells('K'.($b+$i).':L'.($b+$i));
        }
        $where['type'] = '进厂';
        $hglyljcData = Db::name('sqlserver')->where($where)->select()->toArray();
        foreach ($hglyljcData as $key => $value) {
            $sheet->setCellValue('C'.$b,$value['name']);
            $sheet->setCellValue('E'.$b,$value['cheshu']);
            $sheet->setCellValue('G'.$b,$value['net']);
            $sheet->setCellValue('I'.$b,$value['yueleiji']);
            $sheet->setCellValue('K'.$b,$value['kucun']);
            $b++;
        }

        // 出厂
        $sheet->mergeCells('M61:M80');
        $sheet->setCellValue('M61','化工类产品销售情况');
        $sheet->mergeCells('N61:N62');
        $sheet->setCellValue('N61','序号');
        $sheet->mergeCells('O61:P62');
        $sheet->setCellValue('O61','产品名称');
        $sheet->mergeCells('Q61:Q62');
        $sheet->setCellValue('Q61','出厂车数');
        $sheet->mergeCells('R61:R62');
        $sheet->setCellValue('R61','出厂净重');
        $sheet->mergeCells('S61:S62');
        $sheet->setCellValue('S61','月累计出厂');
        $sheet->mergeCells('T61:T62');
        $sheet->setCellValue('T61','库存');
        $sheet->mergeCells('U61:V62');
        $sheet->setCellValue('U61','备注');
        $c = 63;
        for ($i=0; $i < 18; $i++) { 
            $sheet->setCellValue('N'.($c+$i),($i+1));
            $sheet->mergeCells('O'.($c+$i).':P'.($c+$i));
            $sheet->mergeCells('U'.($c+$i).':V'.($c+$i));
        }
        $where['type'] = '出厂';
        $hglcpxsqkData = Db::name('sqlserver')->where($where)->select()->toArray();
        foreach ($hglcpxsqkData as $key => $value) {
            $sheet->setCellValue('O'.$c,$value['name']);
            $sheet->setCellValue('Q'.$c,$value['cheshu']);
            $sheet->setCellValue('R'.$c,$value['net']);
            $sheet->setCellValue('S'.$c,$value['yueleiji']);
            $sheet->setCellValue('T'.$c,$value['kucun']);
            $c++;
        }

        $sheet->mergeCells('A84:V84');
        return $sheet;
    }

    //焦炉生产及工艺控制情况 报表
    public function jlscjgykzqk($sheet,$where){
        $jlscjgykzqkData = Db::name('jlscjgykzqk')->where($where)->select()->toArray();
        if(empty($jlscjgykzqkData)){
            $this->errorMsg = '焦炉生产及工艺控制情况中没有找到已审核数据';
            return $sheet;
        }
        $sheet->mergeCells('A85:V85');
        $sheet->setCellValue('A85','焦炉生产及工艺控制情况');
        $sheet->getStyle('A85')->getFont()->setSize(18);
        $sheet->getStyle('A85:V94')->getFont()->setBold(true);
        $sheet->getStyle('A85')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A86:S89')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        
        $sheet->mergeCells('A86:J86');
        $sheet->mergeCells('K86:S86');
        $sheet->setCellValue('K86','工艺控制情况');
        $sheet->mergeCells('T86:V94');
        
        $sheet->mergeCells('A87:B89');
        $sheet->setCellValue('A87','焦炉炉号');
        $sheet->mergeCells('C87:C88');
        $sheet->setCellValue('C87','计划炉数');
        $sheet->mergeCells('D87:D88');
        $sheet->setCellValue('D87','实际炉数');
        $sheet->mergeCells('C89:E89');
        $sheet->setCellValue('C89','(炉)');
        $sheet->mergeCells('E87:E88');
        $sheet->setCellValue('E87','月累计出炉数');
        $sheet->mergeCells('F87:F88');
        $sheet->setCellValue('F87','日产全焦');
        $sheet->mergeCells('G87:G88');
        $sheet->setCellValue('G87','月累计全焦');
        $sheet->mergeCells('H87:H88');
        $sheet->setCellValue('H87','单炉干基装煤量'); 
        $sheet->mergeCells('I87:I88');
        $sheet->setCellValue('I87','日累计装煤量'); 
        $sheet->mergeCells('J87:J88');
        $sheet->setCellValue('J87','月累计干基装煤量'); 
        $sheet->mergeCells('F89:J89');
        $sheet->setCellValue('F89','（t）'); 
        $sheet->mergeCells('K87:K89');
        $sheet->setCellValue('K87','焦炉炉号'); 
        $sheet->mergeCells('L87:M87');
        $sheet->setCellValue('L87','标准温度'); 
        $sheet->setCellValue('L88','机侧'); 
        $sheet->setCellValue('L89','（℃）'); 
        $sheet->setCellValue('M88','焦侧'); 
        $sheet->setCellValue('M89','（℃）'); 
        $sheet->mergeCells('N87:N88');
        $sheet->setCellValue('N87','循环氨水压力'); 
        $sheet->setCellValue('N89','（Mpa）'); 
        $sheet->mergeCells('O87:O88');
        $sheet->setCellValue('O87','集气管压力'); 
        $sheet->setCellValue('O89','（pa）'); 
        $sheet->mergeCells('P87:P88');
        $sheet->setCellValue('P87','集气管温度'); 
        $sheet->setCellValue('P89','（℃）'); 
        $sheet->mergeCells('Q87:Q88');
        $sheet->setCellValue('Q87','回炉煤气量'); 
        $sheet->mergeCells('R87:R88');
        $sheet->setCellValue('R87','回炉煤气总量'); 
        $sheet->mergeCells('Q89:R89');
        $sheet->setCellValue('Q89','万m³'); 
        $sheet->mergeCells('S87:S88');
        $sheet->setCellValue('S87','热风炉煤气总量');
        $sheet->setCellValue('S89','万m³');

        $a = 90;
        foreach ($jlscjgykzqkData as $key => $value) {
            $sheet->mergeCells('A'.$a.':B'.$a);
            $sheet->setCellValue('A'.$a,($key+1).'号焦炉');
            if(!empty($value['jhls']) && $value['jhls']!=0) {
                $sheet->setCellValue('C'.$a,$value['jhls']);
            }
            if(!empty($value['sjls']) && $value['sjls']!=0) {
                $sheet->setCellValue('D'.$a,$value['sjls']);
            }
            if(!empty($value['yljls']) && $value['yljls']!=0) {
                $sheet->setCellValue('E'.$a,$value['yljls']);
            }
            if(!empty($value['rcqj']) && $value['rcqj']!=0) $sheet->setCellValue('F'.$a,$value['rcqj']);
            if(!empty($value['yljqj']) && $value['yljqj']!=0) $sheet->setCellValue('G'.$a,$value['yljqj']);
            if(!empty($value['dlzml']) && $value['dlzml']!=0) {
                $sheet->setCellValue('H'.$a,$value['dlzml']);
            }
            if(!empty($value['rljzml']) && $value['rljzml']!=0) {
                $sheet->setCellValue('I'.$a,$value['rljzml']);
            }
            if(!empty($value['yljzml']) && $value['yljzml']!=0) {
                $sheet->setCellValue('J'.$a,$value['yljzml']);
            }
            $sheet->setCellValue('K'.$a,($key+1).'#焦炉');
            if(!empty($value['jice']) && $value['jice']!=0) $sheet->setCellValue('L'.$a,$value['jice']);
            if(!empty($value['jiaoce']) && $value['jiaoce']!=0) $sheet->setCellValue('M'.$a,$value['jiaoce']);
            if(!empty($value['xhasyl']) && $value['xhasyl']!=0) $sheet->setCellValue('N'.$a,$value['xhasyl']);
            if(!empty($value['jqgyl']) && $value['jqgyl']!=0) $sheet->setCellValue('O'.$a,$value['jqgyl']);
            if(!empty($value['jqgwd']) && $value['jqgwd']!=0) $sheet->setCellValue('P'.$a,$value['jqgwd']);
            if(!empty($value['hlmql']) && $value['hlmql']!=0) {
                $sheet->setCellValue('Q'.$a,$value['hlmql']);
            }
            if(!empty($value['hlmqzl']) && $value['hlmqzl']!=0) {
                $sheet->setCellValue('R'.$a,$value['hlmqzl']);
            }
            if(!empty($value['rflmqzl']) && $value['rflmqzl']!=0) {
                $sheet->setCellValue('S'.$a,$value['rflmqzl']);
            }
            $sheet->setCellValue('T86',$value['content']);
            $a++;
        }

        $sheet->setCellValue('S90','1#');
        $sheet->setCellValue('S92','2#');

        $styleArray2 = [
            'alignment' => [
                'horizontal' => Alignment::HORIZONTAL_LEFT,
                'vertical'=>Alignment::VERTICAL_TOP
            ],
        ];
        $sheet->getStyle('T86')->applyFromArray($styleArray2);

        $sheet->mergeCells('A94:B94');
        $sheet->setCellValue('A94','合计');
        $sheet->setCellValue('C94',"=SUM(C90:C93)");
        $sheet->setCellValue('D94',"=SUM(D90:D93)");
        $sheet->setCellValue('E94',"=SUM(E90:E93)");
        $sheet->setCellValue('H94',"=AVERAGE(H90:H93)");
        $sheet->setCellValue('I94',"=SUM(I90:I93)");
        $sheet->setCellValue('J94',"=SUM(J90:J93)");
        $sheet->setCellValue('Q94',"=Q90+Q91+Q92+Q93");
        $sheet->setCellValue('R94',"=R90+R91+R92+R93");
        $sheet->setCellValue('S94',"=S91+S93");

        $sheet->mergeCells('A95:V95');

        return $sheet;
    }

    //干熄炉生产及工艺控制情况 报表
    public function gxlscjgykzqk($sheet,$where){
        $gxlscjgykzqkData = Db::name('gxlscjgykzqk')->where($where)->select()->toArray();
        if(empty($gxlscjgykzqkData)){
            $this->errorMsg = '干熄炉生产及工艺控制情况中没有找到已审核数据';
            return $sheet;
        }
        $sheet->mergeCells('A96:V96');
        $sheet->setCellValue('A96','干熄炉生产及工艺控制情况');
        $sheet->getStyle('A96')->getFont()->setSize(18);
        $sheet->getStyle('A96:V104')->getFont()->setBold(true);
        $sheet->getStyle('A96')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A97:S97')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('C98:L99')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('N98:R99')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('S98')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('S100')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('S102')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A104:J104')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('O104')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('K101:K103')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('L103')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        
        $sheet->mergeCells('A97:L97');
        $sheet->setCellValue('A97','生产情况');
        $sheet->mergeCells('M97:S97');
        $sheet->setCellValue('M97','工艺控制情况');
        $sheet->mergeCells('A98:B101');
        $sheet->setCellValue('A98','干熄炉炉号');
        $sheet->mergeCells('C98:C99');
        $sheet->setCellValue('C98','出炉数');
        $sheet->mergeCells('D98:D99');
        $sheet->setCellValue('D98','月累计出炉数');
        $sheet->mergeCells('C100:D101');
        $sheet->setCellValue('C100','(炉)');
        $sheet->mergeCells('E98:E99');
        $sheet->setCellValue('E98','干焦日产量');
        $sheet->mergeCells('F98:F99');
        $sheet->setCellValue('F98','干焦月累计产量');
        $sheet->mergeCells('E100:F101');
        $sheet->setCellValue('E100','（t）');
        $sheet->mergeCells('G98:G99');
        $sheet->setCellValue('G98','污氮日耗量');
        $sheet->mergeCells('H98:H99');
        $sheet->setCellValue('H98','污氮月累计耗量');
        $sheet->mergeCells('G100:H101');
        $sheet->setCellValue('G100','（万m3）');
        $sheet->mergeCells('I98:J99');
        $sheet->setCellValue('I98','各处焦炭料位(m)');
        $sheet->setCellValue('I100','筛焦楼');
        $sheet->setCellValue('I101','中间仓');
        $sheet->setCellValue('I102','干熄炉');
        $sheet->setCellValue('I103','大焦仓');
        $sheet->setCellValue('I104','火运仓');


        $sheet->mergeCells('K98:L98');
        $sheet->setCellValue('K98','汽机发电量（万kw·h）');
        $sheet->setCellValue('K99','1#日发电量');
        $sheet->setCellValue('L99','2#日发电量');
        $sheet->setCellValue('K101','月累计量');
        $sheet->mergeCells('K102:L102');
        $sheet->setCellValue('K102','外送蒸汽量（t）');
        $sheet->setCellValue('K103','日外送量');
        $sheet->setCellValue('L103','月累计量');

        $sheet->mergeCells('M98:M101');
        $sheet->setCellValue('M98','干熄炉炉号');
        $sheet->mergeCells('N98:P98');
        $sheet->setCellValue('N98','蒸汽指标');
        $sheet->setCellValue('N99','压力');
        $sheet->mergeCells('N100:N101');
        $sheet->setCellValue('N100','（Mpa）');
        $sheet->setCellValue('O99','流量');
        $sheet->mergeCells('O100:O101');
        $sheet->setCellValue('O100','（t）');
        $sheet->setCellValue('P99','温度');
        $sheet->mergeCells('P100:P101');
        $sheet->setCellValue('P100','（℃）');
        $sheet->mergeCells('Q98:Q99');
        $sheet->setCellValue('Q98','循环风量');
        $sheet->mergeCells('Q100:Q101');
        $sheet->setCellValue('Q100','万m3/h');
        $sheet->mergeCells('R98:R99');
        $sheet->setCellValue('R98','排焦温度');
        $sheet->mergeCells('R100:R101');
        $sheet->setCellValue('R100','（℃）');
        $sheet->setCellValue('S98','焦粉');
        $sheet->setCellValue('S100','焦末');
        $sheet->setCellValue('S102','平均装焦量');
        $sheet->mergeCells('T97:V104');
        
        $a = 102;
        foreach ($gxlscjgykzqkData as $key => $value) {
            $sheet->mergeCells('A'.$a.':B'.$a);
            $sheet->setCellValue('A'.$a,($key+1).'#干熄炉');

            if(!empty($value['cls']) && $value['cls']!=0) {
                $sheet->setCellValue('C'.$a,$value['cls']);
            }
            if(!empty($value['yljcls']) && $value['yljcls']!=0) {
                $sheet->setCellValue('D'.$a,$value['yljcls']);
            }
            if(!empty($value['gjrcl']) && $value['gjrcl']!=0) {
                $sheet->setCellValue('E'.$a,$value['gjrcl']);
            }
            if(!empty($value['gjycl']) && $value['gjycl']!=0) {
                $sheet->setCellValue('F'.$a,$value['gjycl']);
            }
            if(!empty($value['wdrhl']) && $value['wdrhl']!=0) {
                $sheet->setCellValue('G'.$a,$value['wdrhl']);
            }
            if(!empty($value['wdyhl']) && $value['wdyhl']!=0) {
                $sheet->setCellValue('H'.$a,$value['wdyhl']);
            }
            
            $sheet->setCellValue('M'.$a,($key+1).'#炉');
            if(!empty($value['yali']) && $value['yali']!=0) $sheet->setCellValue('N'.$a,$value['yali']);
            if(!empty($value['liuliang']) && $value['liuliang']!=0) {
                $sheet->setCellValue('O'.$a,$value['liuliang']);
            }
            if(!empty($value['wendu']) && $value['wendu']!=0) $sheet->setCellValue('P'.$a,$value['wendu']);
            if(!empty($value['xhfl']) && $value['xhfl']!=0) $sheet->setCellValue('Q'.$a,$value['xhfl']);
            if(!empty($value['pjwd']) && $value['pjwd']!=0) $sheet->setCellValue('R'.$a,$value['pjwd']);

            
            if(!empty($value['onefdl']) && $value['onefdl']!=0) $sheet->setCellValue('K100',$value['onefdl']);
            if(!empty($value['twofdl']) && $value['twofdl']!=0) $sheet->setCellValue('L100',$value['twofdl']);
            if(!empty($value['yljfdl']) && $value['yljfdl']!=0) $sheet->setCellValue('L101',$value['yljfdl']);
            if(!empty($value['wsrwsl']) && $value['wsrwsl']!=0) $sheet->setCellValue('K104',$value['wsrwsl']);
            if(!empty($value['wsyljl']) && $value['wsyljl']!=0) $sheet->setCellValue('L104',$value['wsyljl']);
            if(!empty($value['jiaofen']) && $value['jiaofen']!=0) $sheet->setCellValue('S99',$value['jiaofen']);
            if(!empty($value['jiaomo']) && $value['jiaomo']!=0) $sheet->setCellValue('S101',$value['jiaomo']);
            if(!empty($value['pjzjl']) && $value['pjzjl']!=0) $sheet->setCellValue('S103',$value['pjzjl']);
            if(!empty($value['shaijl']) && $value['shaijl']!=0) $sheet->setCellValue('J100',$value['shaijl']);
            if(!empty($value['zhongjc']) && $value['zhongjc']!=0) $sheet->setCellValue('J101',$value['zhongjc']);
            if(!empty($value['ganxl']) && $value['ganxl']!=0) $sheet->setCellValue('J102',$value['ganxl']);
            if(!empty($value['dajc']) && $value['dajc']!=0) $sheet->setCellValue('J103',$value['dajc']);
            if(!empty($value['huoyc']) && $value['huoyc']!=0) $sheet->setCellValue('J104',$value['huoyc']);

            $sheet->setCellValue('T97',$value['content']);
            $a++;
        }

        
        $sheet->mergeCells('A104:B104');
        $sheet->setCellValue('A104','合计');
        $sheet->setCellValue('C104',"=C102+C103");
        $sheet->setCellValue('D104',"=D102+D103");
        $sheet->setCellValue('E104',"=E102+E103");
        $sheet->setCellValue('F104',"=F102+F103");
        $sheet->setCellValue('G104',"=G102+G103");
        $sheet->setCellValue('H104',"=H102+H103");
        $sheet->setCellValue('O104',"=O102+O103");


        $sheet->mergeCells('A105:V105');

        return $sheet;
    }

    //净化生产及工艺控制情况 报表
    public function jhscjgykzqk($sheet,$where){
        $info = Db::name('jhscjgykzqk')->where($where)->find();
        if(empty($info)){
            $this->errorMsg = '净化生产及工艺控制情况中没有找到已审核数据';
            return $sheet;
        }
        $sheet->mergeCells('A106:V106');
        $sheet->setCellValue('A106','净化生产及工艺控制情况');
        $sheet->getStyle('A106')->getFont()->setSize(18);
        $sheet->getStyle('A106:V124')->getFont()->setBold(true);
        $sheet->getStyle('A106:V108')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A109:B124')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('M109:M124')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('S113:V113')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        
        $sheet->mergeCells('A107:V107');
        $sheet->setCellValue('A107','工艺控制情况');
        $sheet->mergeCells('A108:B108');
        $sheet->setCellValue('A108','项目');
        $sheet->mergeCells('A109:B111');
        $sheet->setCellValue('A109','冷凝');
        $sheet->mergeCells('A112:B114');
        $sheet->setCellValue('A112','鼓风机');
        $sheet->mergeCells('A115:B117');
        $sheet->setCellValue('A115','蒸氨');
        $sheet->mergeCells('A118:B120');
        $sheet->setCellValue('A118','硫铵');
        $sheet->mergeCells('A121:B124');
        $sheet->setCellValue('A121','粗苯');
        
        $sheet->mergeCells('M108:N108');
        $sheet->setCellValue('M108','项目');
        $sheet->mergeCells('M109:N112');
        $sheet->setCellValue('M109','硫化氢');
        $sheet->mergeCells('M113:N116');
        $sheet->setCellValue('M113','污水处理');
        $sheet->mergeCells('M117:V117');
        $sheet->setCellValue('M117','产量');

        $arr = [
            "name"=>["设备名称","器后温度","器前吸力","循环氨水","机前吸力","机后压力","煤气流量","塔顶温度","塔底压力","剩余氨水去蒸氨塔","母液酸度","母液温度","饱和器阻力","终冷塔后煤气温度","富油预热温度","富油流量","冷贫油温度",],
            "danwei"=>["单位","℃","Kpa","m³/h","Kpa","Kpa","m³/h","℃","Kpa","m³","%","℃","Kpa",
            "℃","℃","m³/h","℃",],
            "bai"=>["白班",$info['qhwdb'],$info['qqxlb'],$info['xhasb'],$info['jqxlb'],$info['jhylb'],$info['mqllb'],$info['tdwdb'],$info['tdylb'],$info['syasb'],$info['mysdb'],$info['mywdb'],$info['bhqzlb'],$info['zltwdb'],$info['fyyrwdb'],$info['fyllb'],$info['lpywdb'],$info['zltwdb']],
            "ye"=>["夜班",$info['qhwdy'],$info['qqxly'],$info['xhasy'],$info['jqxly'],$info['jhyly'],$info['mqlly'],$info['tdwdy'],$info['tdyly'],$info['syasy'],$info['mysdy'],$info['mywdy'],$info['bhqzly'],$info['zltwdy'],$info['fyyrwdy'],$info['fylly'],$info['lpywdy'],$info['zltwdy']]
        ];
        
        $a = 108;
        foreach ($arr as $key => $value) {
            if($key=='name'){
                foreach ($value as $k => $v) {
                    $sheet->mergeCells('C'.($k+$a).':E'.($k+$a));
                    $sheet->setCellValue('C'.($k+$a),$v);
                }
            }
            if($key=='danwei'){
                foreach ($value as $k => $v) {
                    $sheet->setCellValue('F'.($k+$a),$v);
                }
            }
            if($key=='bai'){
                foreach ($value as $k => $v) {
                    $sheet->mergeCells('G'.($k+$a).':I'.($k+$a));
                    $sheet->setCellValue('G'.($k+$a),$v);
                }
            }
            if($key=='ye'){
                foreach ($value as $k => $v) {
                    $sheet->mergeCells('J'.($k+$a).':L'.($k+$a));
                    $sheet->setCellValue('J'.($k+$a),$v);
                }
            }
        }

        $arr1 = [
            "name"=>["设备名称","鼓冷","1#脱硫塔","2#脱硫塔","饱和器出口",],
            "danwei"=>["单位","mg/m³","mg/m³","mg/m³","mg/m³",],
            "zhibiao"=>["指标",$info['guleng'],$info['tuoliuta1'],$info['tuoliuta2'],$info['bhqck']]
        ];
        
        foreach ($arr1 as $key => $value) {
            if($key=='name'){
                foreach ($value as $k => $v) {
                    $sheet->mergeCells('O'.($k+$a).':Q'.($k+$a));
                    $sheet->setCellValue('O'.($k+$a),$v);
                }
            }
            if($key=='danwei'){
                foreach ($value as $k => $v) {
                    $sheet->setCellValue('R'.($k+$a),$v);
                }
            }
            if($key=='zhibiao'){
                foreach ($value as $k => $v) {
                    $sheet->mergeCells('S'.($k+$a).':V'.($k+$a));
                    $sheet->setCellValue('S'.($k+$a),$v);
                }
            }
        }

        $arr2 = [
            "name"=>["","新生化","老生化","深度处理"],
            "danwei"=>["单位","t","t","t"],
            "ri"=>["日处理量",$info['xshr'],$info['lshr'],$info['sdclr']],
            "yue"=>["月累计处理量",$info['xshy'],$info['lshy'],$info['sdcly']]
        ];
        $b = 113;
        foreach ($arr2 as $key => $value) {
            if($key=='name'){
                foreach ($value as $k => $v) {
                    $sheet->mergeCells('O'.($k+$b).':Q'.($k+$b));
                    $sheet->setCellValue('O'.($k+$b),$v);
                }
            }
            if($key=='danwei'){
                foreach ($value as $k => $v) {
                    $sheet->setCellValue('R'.($k+$b),$v);
                }
            }
            if($key=='ri'){
                foreach ($value as $k => $v) {
                    $sheet->mergeCells('S'.($k+$b).':T'.($k+$b));
                    $sheet->setCellValue('S'.($k+$b),$v);
                }
            }
            if($key=='yue'){
                foreach ($value as $k => $v) {
                    $sheet->mergeCells('U'.($k+$b).':V'.($k+$b));
                    $sheet->setCellValue('U'.($k+$b),$v);
                }
            }
        }

        $arr3 = [
            "name"=>["产品名称","煤气","焦油","硫铵","粗苯","硫磺","副盐",],
            "danwei"=>["单位","万m³","t","t","t","t","包",],
            "ri"=>["日产量",$info['meiqir'],$info['jiaoyour'],$info['liuanr'],$info['cubenr'],$info['liuhuangr'],$info['fuyanr']],
            "yue"=>["月累计产量",$info['meiqiy'],$info['jiaoyouy'],$info['liuany'],$info['cubeny'],$info['liuhuangy'],$info['fuyany']]
        ];
        $c = 118;
        foreach ($arr3 as $key => $value) {
            if($key=='name'){
                foreach ($value as $k => $v) {
                    $sheet->mergeCells('M'.($k+$c).':O'.($k+$c));
                    $sheet->setCellValue('M'.($k+$c),$v);
                }
            }
            if($key=='danwei'){
                foreach ($value as $k => $v) {
                    $sheet->setCellValue('P'.($k+$c),$v);
                }
            }
            if($key=='ri'){
                foreach ($value as $k => $v) {
                    $sheet->mergeCells('Q'.($k+$c).':S'.($k+$c));
                    $sheet->setCellValue('Q'.($k+$c),$v);
                }
            }
            if($key=='yue'){
                foreach ($value as $k => $v) {
                    $sheet->mergeCells('T'.($k+$c).':V'.($k+$c));
                    $sheet->setCellValue('T'.($k+$c),$v);
                }
            }
        }
        
        $sheet->mergeCells('A125:V125');

        return $sheet;
    }

    //动力生产情况 报表
    public function dlscqk($sheet,$where){
        $info = Db::name('dlscqk')->where($where)->find();
        if(empty($info)){
            $this->errorMsg = '动力生产情况中没有找到已审核数据';
            return $sheet;
        }
        $sheet->mergeCells('A126:V126');
        $sheet->setCellValue('A126','动力生产情况');
        $sheet->getStyle('A126')->getFont()->setSize(18);
        $sheet->getStyle('A126:V144')->getFont()->setBold(true);
        $sheet->getStyle('A126')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A127:P128')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A131:P132')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A135:P136')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A138:P139')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A140:B144')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('C144:K144')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        
        $sheet->mergeCells('A127:D127');
        $sheet->setCellValue('A127','用电量（万kw·h）');
        $sheet->mergeCells('E127:I127');
        $sheet->setCellValue('E127','接收中浩电量（万kw·h）');
        $sheet->mergeCells('J127:M127');
        $sheet->setCellValue('J127','11万站接电量（万kw·h）');
        $sheet->mergeCells('N127:O127');
        $sheet->setCellValue('N127','氨水（t）');
        $sheet->mergeCells('P127:P128');
        $sheet->setCellValue('P127','制水');
        $sheet->mergeCells('Q127:V144');
        $sheet->setCellValue('Q127',$info['content']);
        $styleArray2 = [
            'alignment' => [
                'horizontal' => Alignment::HORIZONTAL_LEFT,
                'vertical'=>Alignment::VERTICAL_TOP
            ],
        ];
        $sheet->getStyle('Q127')->applyFromArray($styleArray2);
        
        $sheet->mergeCells('A128:B128');
        $sheet->setCellValue('A128','日用量');
        $sheet->mergeCells('C128:D128');
        $sheet->setCellValue('C128','月累计量');
        $sheet->mergeCells('E128:F128');
        $sheet->setCellValue('E128','日接收量');
        $sheet->mergeCells('G128:I128');
        $sheet->setCellValue('G128','月累积量');
        $sheet->mergeCells('J128:K128');
        $sheet->setCellValue('J128','日接收量');
        $sheet->mergeCells('L128:M128');
        $sheet->setCellValue('L128','月累积量');
        $sheet->setCellValue('N128','日用量');
        $sheet->setCellValue('O128','月累积量');

        $sheet->mergeCells('A129:B130');
        $sheet->setCellValue('A129',$info['ydlr']);
        $sheet->mergeCells('C129:D130');
        $sheet->setCellValue('C129',$info['ydly']);
        $sheet->mergeCells('E129:F130');
        $sheet->setCellValue('E129',$info['jsdlr']);
        $sheet->mergeCells('G129:I130');
        $sheet->setCellValue('G129',$info['jsdly']);
        $sheet->mergeCells('J129:K130');
        $sheet->setCellValue('J129',$info['wzdlr']);
        $sheet->mergeCells('L129:M130');
        $sheet->setCellValue('L129',$info['wzdly']);
        $sheet->mergeCells('N129:N130');
        $sheet->setCellValue('N129',$info['anshuir']);
        $sheet->mergeCells('O129:O130');
        $sheet->setCellValue('O129',$info['anshuiy']);
        $sheet->mergeCells('P129:P130');
        $sheet->setCellValue('P129',$info['zhishui']);

        $sheet->mergeCells('A131:D131');
        $sheet->setCellValue('A131','中水回收水量（t)');
        $sheet->mergeCells('E131:H131');
        $sheet->setCellValue('E131','雨水排量');
        $sheet->mergeCells('I131:I132');
        $sheet->setCellValue('I131','干熄用水');
        $sheet->mergeCells('J131:N131');
        $sheet->setCellValue('J131','煤气掺烧（万m3）');
        $sheet->mergeCells('O131:O132');
        $sheet->setCellValue('O131','低压');
        $sheet->mergeCells('P131:P132');
        $sheet->setCellValue('P131','原水');
        
        $sheet->setCellValue('A132','进水');
        $sheet->setCellValue('B132','月累计');
        $sheet->setCellValue('C132','出水');
        $sheet->setCellValue('D132','月累计');

        $sheet->mergeCells('E132:F132');
        $sheet->setCellValue('E132','日排量');
        $sheet->mergeCells('G132:H132');
        $sheet->setCellValue('G132','月累积量');
        $sheet->mergeCells('J132:K132');
        $sheet->setCellValue('J132','4#');
        $sheet->mergeCells('L132:M132');
        $sheet->setCellValue('L132','5#');
        $sheet->setCellValue('N132','合计');

        $sheet->mergeCells('A133:A134');
        $sheet->setCellValue('A133',$info['zsjs']);
        $sheet->mergeCells('B133:B134');
        $sheet->setCellValue('B133',$info['zsjsylj']);
        $sheet->mergeCells('C133:C134');
        $sheet->setCellValue('C133',$info['zscs']);
        $sheet->mergeCells('D133:D134');
        $sheet->setCellValue('D133',$info['zscsylj']);
        
        $sheet->mergeCells('E133:F134');
        $sheet->setCellValue('E133',$info['ysr']);
        $sheet->mergeCells('G133:H134');
        $sheet->setCellValue('G133',$info['ysy']);
        $sheet->mergeCells('I133:I134');
        $sheet->setCellValue('I133',$info['gxys']);
        $sheet->mergeCells('J133:K134');
        $sheet->setCellValue('J133',$info['mqcs4']);
        $sheet->mergeCells('L133:M134');
        $sheet->setCellValue('L133',$info['mqcs5']);
        $sheet->mergeCells('N133:N134');
        $sheet->setCellValue('N133',$info['mqcshj']);
        $sheet->mergeCells('O133:O134');
        $sheet->setCellValue('O133',$info['diya']);
        $sheet->mergeCells('P133:P134');
        $sheet->setCellValue('P133',$info['yuanshui']);

        $sheet->mergeCells('A135:C135');
        $sheet->setCellValue('A135','浩源（一、二期）');
        $sheet->mergeCells('D135:J135');
        $sheet->setCellValue('D135','浩淼（三期）');
        $sheet->mergeCells('K135:K136');
        $sheet->setCellValue('K135','日总计量');
        $sheet->mergeCells('L135:L136');
        $sheet->setCellValue('L135','月累计量');
        $sheet->mergeCells('M135:P135');
        $sheet->setCellValue('M135','甲醇新鲜水池出水');
        $sheet->setCellValue('A136','动力老站');
        $sheet->setCellValue('B136','其它');
        $sheet->setCellValue('C136','合计');
        $sheet->setCellValue('D136','甲醇循环水');
        $sheet->setCellValue('E136','甲醇新鲜水池');
        $sheet->setCellValue('F136','净化循环水');
        $sheet->setCellValue('G136','干熄循环水');
        $sheet->setCellValue('H136','中水循环水');
        $sheet->setCellValue('I136','差值');
        $sheet->setCellValue('J136','合计');
        $sheet->mergeCells('M136:N136');
        $sheet->setCellValue('M136','动力新站');
        $sheet->mergeCells('O136:P136');
        $sheet->setCellValue('O136','甲醇循环水');
        
        $sheet->setCellValue('A137',$info['hydllz']);
        $sheet->setCellValue('B137',$info['hyqt']);
        $sheet->setCellValue('C137',$info['hyhj']);
        $sheet->setCellValue('D137',$info['hsjcxhs']);
        $sheet->setCellValue('E137',$info['hsjcxxs']);
        $sheet->setCellValue('F137',$info['hsjhs']);
        $sheet->setCellValue('G137',$info['hsgxs']);
        $sheet->setCellValue('H137',$info['hszs']);
        $sheet->setCellValue('I137',$info['hscz']);
        $sheet->setCellValue('J137',$info['hshj']);
        $sheet->setCellValue('K137',$info['rzjl']);
        $sheet->setCellValue('L137',$info['yljl']);
        $sheet->mergeCells('M137:N137');
        $sheet->setCellValue('M137',$info['jcdlxz']);
        $sheet->mergeCells('O137:P137');
        $sheet->setCellValue('O137',$info['jcxhs']);

        $sheet->mergeCells('A138:B139');
        $sheet->setCellValue('A138','锅炉');
        $sheet->mergeCells('C138:F138');
        $sheet->setCellValue('C138','蒸汽产量（t）');
        $sheet->mergeCells('G138:K138');
        $sheet->setCellValue('G138','耗煤量（t)');
        $sheet->mergeCells('L138:N139');
        $sheet->setCellValue('L138','动力煤存储量（t）');
        $sheet->mergeCells('O138:P139');
        $sheet->setCellValue('O138','来煤');
        $sheet->mergeCells('C139:D139');
        $sheet->setCellValue('C139','日产量');
        $sheet->mergeCells('E139:F139');
        $sheet->setCellValue('E139','月累计产量');
        $sheet->mergeCells('G139:I139');
        $sheet->setCellValue('G139','日耗量');
        $sheet->mergeCells('J139:K139');
        $sheet->setCellValue('J139','月累计耗量');
        $sheet->mergeCells('A140:B141');
        $sheet->setCellValue('A140','40T');
        $sheet->mergeCells('C140:D141');
        $sheet->setCellValue('C140',$info['zq40rc']);
        $sheet->mergeCells('E140:F141');
        $sheet->setCellValue('E140',$info['zq40yc']);
        $sheet->mergeCells('G140:I141');
        $sheet->setCellValue('G140',$info['hm40rh']);
        $sheet->mergeCells('J140:K141');
        $sheet->setCellValue('J140',$info['hm40yh']);

        $sheet->mergeCells('A142:B143');
        $sheet->setCellValue('A142','75T');
        $sheet->mergeCells('C142:D143');
        $sheet->setCellValue('C142',$info['zq75rc']);
        $sheet->mergeCells('E142:F143');
        $sheet->setCellValue('E142',$info['zq75yc']);
        $sheet->mergeCells('G142:I143');
        $sheet->setCellValue('G142',$info['hm75rh']);
        $sheet->mergeCells('J142:K143');
        $sheet->setCellValue('J142',$info['hm75yh']);
        $sheet->mergeCells('L140:N144');
        $sheet->setCellValue('L140',$info['dlmccl']);
        $sheet->mergeCells('O140:P144');
        $sheet->setCellValue('O140',$info['laimei']);

        $sheet->mergeCells('A144:B144');
        $sheet->setCellValue('A144','合计');
        $sheet->mergeCells('C144:D144');
        $sheet->setCellValue('C144',"=C140+C142");
        $sheet->mergeCells('E144:F144');
        $sheet->setCellValue('E144',"=E140+E142");
        $sheet->mergeCells('G144:I144');
        $sheet->setCellValue('G144',"=G140+G142");
        $sheet->mergeCells('J144:K144');
        $sheet->setCellValue('J144',"=J140+J142");
        
        
        $sheet->mergeCells('A145:V145');

        return $sheet;
    }

    
    //甲醇生产情况 报表
    public function jcscqk($sheet,$where){
        $info = Db::name('jcscqk')->where($where)->find();
        if(empty($info)){
            $this->errorMsg = '甲醇生产情况中没有找到已审核数据';
            return $sheet;
        }
        $sheet->mergeCells('A146:V146');
        $sheet->setCellValue('A146','甲醇生产情况');
        $sheet->getStyle('A146')->getFont()->setSize(18);
        $sheet->getStyle('A146:V157')->getFont()->setBold(true);
        $sheet->getStyle('A146')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A147:O148')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('F150:G150')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A151:A157')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('B154:V155')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');

        $sheet->mergeCells('A147:A150');
        $sheet->setCellValue('A147','生产情况');
        $sheet->mergeCells('B147:E147');
        $sheet->setCellValue('B147','甲醇产量（t）');
        $sheet->mergeCells('F147:F148');
        $sheet->setCellValue('F147','A罐库存  （t）');
        $sheet->mergeCells('G147:G148');
        $sheet->setCellValue('G147','B罐库存  （t）');
        $sheet->mergeCells('H147:K147');
        $sheet->setCellValue('H147','副盐（包）');
        $sheet->mergeCells('L147:O147');
        $sheet->setCellValue('L147','耗煤气量（万m³）');
        $sheet->mergeCells('P147:V153');
        $sheet->setCellValue('P147',$info['content']);
        $styleArray2 = [
            'alignment' => [
                'horizontal' => Alignment::HORIZONTAL_LEFT,
                'vertical'=>Alignment::VERTICAL_TOP
            ],
        ];
        $sheet->getStyle('P147')->applyFromArray($styleArray2);
        
        $sheet->mergeCells('B148:C148');
        $sheet->setCellValue('B148','日产量');
        $sheet->mergeCells('D148:E148');
        $sheet->setCellValue('D148','月累计产量');
        $sheet->mergeCells('H148:I148');
        $sheet->setCellValue('H148','日量');
        $sheet->mergeCells('J148:K148');
        $sheet->setCellValue('J148','月累积量');
        $sheet->mergeCells('L148:M148');
        $sheet->setCellValue('L148','日量');
        $sheet->mergeCells('N148:O148');
        $sheet->setCellValue('N148','月累积量');
        $sheet->mergeCells('B149:C150');
        $sheet->setCellValue('B149',$info['jcr']);
        $sheet->mergeCells('D149:E150');
        $sheet->setCellValue('D149',$info['jcy']);
        $sheet->setCellValue('F149',$info['agkc']);
        $sheet->setCellValue('G149',$info['bgkc']);
        $sheet->mergeCells('F150:G150');
        $sheet->setCellValue('F150',"=F149+G149");
        $sheet->mergeCells('H149:I150');
        $sheet->setCellValue('H149',$info['fyr']);
        $sheet->mergeCells('J149:K150');
        $sheet->setCellValue('J149',$info['fyy']);
        $sheet->mergeCells('L149:M150');
        $sheet->setCellValue('L149',$info['hmr']);
        $sheet->mergeCells('N149:O150');
        $sheet->setCellValue('N149',$info['hmy']);
        $sheet->mergeCells('A151:A153');
        $sheet->setCellValue('A151','煤气组分分析');
        $sheet->mergeCells('B151:C151');
        $sheet->setCellValue('B151','总碳（%）');
        $sheet->mergeCells('D151:E151');
        $sheet->setCellValue('D151','CO（%）');
        $sheet->mergeCells('F151:G151');
        $sheet->setCellValue('F151','CO2（%）');
        $sheet->mergeCells('H151:I151');
        $sheet->setCellValue('H151','CH4（%）');
        $sheet->mergeCells('J151:K151');
        $sheet->setCellValue('J151','H2（%）');
        $sheet->mergeCells('L151:M151');
        $sheet->setCellValue('L151','N2（%）');
        $sheet->mergeCells('N151:O151');
        $sheet->setCellValue('N151','O2（%）');
        $sheet->mergeCells('B152:C153');
        $sheet->setCellValue('B152',$info['zt']);
        $sheet->mergeCells('D152:E153');
        $sheet->setCellValue('D152',$info['co']);
        $sheet->mergeCells('F152:G153');
        $sheet->setCellValue('F152',$info['co2']);
        $sheet->mergeCells('H152:I153');
        $sheet->setCellValue('H152',$info['ch4']);
        $sheet->mergeCells('J152:K153');
        $sheet->setCellValue('J152',$info['h2']);
        $sheet->mergeCells('L152:M153');
        $sheet->setCellValue('L152',$info['n2']);
        $sheet->mergeCells('N152:O153');
        $sheet->setCellValue('N152',$info['o2']);

        $sheet->mergeCells('A154:A157');
        $sheet->setCellValue('A154','煤气组分分析');
        $sheet->mergeCells('B154:C155');
        $sheet->setCellValue('B154','气柜高度（m）');
        $sheet->mergeCells('D154:E155');
        $sheet->setCellValue('D154','湿脱硫出口平均煤气流量（m³/h）');
        $sheet->mergeCells('F154:G155');
        $sheet->setCellValue('F154','进口压力（Kpa）');
        $sheet->mergeCells('H154:I155');
        $sheet->setCellValue('H154','送净化废水（t)');
        $sheet->mergeCells('J154:J157');
        $sheet->setCellValue('J154','湿脱硫');
        $sheet->mergeCells('K154:N155');
        $sheet->setCellValue('K154','H2S（mg/Nm³）');
        $sheet->mergeCells('K156:N156');
        $sheet->setCellValue('K156','入口');
        $sheet->mergeCells('K157:N157');
        $sheet->setCellValue('K157','出口');
        $sheet->mergeCells('O154:P155');
        $sheet->setCellValue('O154','一期');
        $sheet->mergeCells('Q154:R155');
        $sheet->setCellValue('Q154','二期');
        $sheet->mergeCells('S154:T155');
        $sheet->setCellValue('S154','三期');
        $sheet->mergeCells('U154:V155');
        $sheet->setCellValue('U154','低压蒸汽压力（Mpa）');

        $sheet->mergeCells('B156:C157');
        $sheet->setCellValue('B156',$info['qggd']);
        $sheet->mergeCells('D156:E157');
        $sheet->setCellValue('D156',$info['mqll']);
        $sheet->mergeCells('F156:G157');
        $sheet->setCellValue('F156',$info['jkyl']);
        $sheet->mergeCells('H156:I157');
        $sheet->setCellValue('H156',$info['jhfs']);
        $sheet->mergeCells('O156:T156');
        $sheet->setCellValue('O156',$info['rukou']);
        $sheet->mergeCells('O157:P157');
        $sheet->setCellValue('O157',$info['chukou1']);
        $sheet->mergeCells('Q157:R157');
        $sheet->setCellValue('Q157',$info['chukou2']);
        $sheet->mergeCells('S157:T157');
        $sheet->setCellValue('S157',$info['chukou3']);
        $sheet->mergeCells('U156:V157');
        $sheet->setCellValue('U156',$info['zqyl']);

        $sheet->mergeCells('A158:V158');

        return $sheet;
    }
    
    //精苯生产情况 报表
    public function jbscqk($sheet,$where){
        $info = Db::name('jbscqk')->where($where)->find();
        if(empty($info)){
            $this->errorMsg = '精苯生产情况中没有找到已审核数据';
            return $sheet;
        }
        $sheet->mergeCells('A159:V159');
        $sheet->setCellValue('A159','精苯生产情况');
        $sheet->getStyle('A159')->getFont()->setSize(18);
        $sheet->getStyle('A159:V174')->getFont()->setBold(true);
        $sheet->getStyle('A159')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A160:R161')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A164:R164')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('O165:R165')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A167:N167')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A168:V168')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('B169:C171')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A172:M172')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A174')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');

        $sheet->mergeCells('A160:B161');
        $sheet->setCellValue('A160','粗苯进车数');
        $sheet->mergeCells('C160:F160');
        $sheet->setCellValue('C160','粗苯进厂量（t）');
        $sheet->mergeCells('G160:J160');
        $sheet->setCellValue('G160','粗苯加工量（t）');
        $sheet->mergeCells('K160:N160');
        $sheet->setCellValue('K160','纯苯产生量（t）');
        $sheet->mergeCells('O160:P161');
        $sheet->setCellValue('O160','三苯收率（%）');
        $sheet->mergeCells('Q160:R161');
        $sheet->setCellValue('Q160','纯苯收率（%）');
        $sheet->mergeCells('S160:V167');
        $sheet->setCellValue('S160',$info['content']);
        $styleArray2 = [
            'alignment' => [
                'horizontal' => Alignment::HORIZONTAL_LEFT,
                'vertical'=>Alignment::VERTICAL_TOP
            ],
        ];
        $sheet->getStyle('S160')->applyFromArray($styleArray2);
        $sheet->mergeCells('C161:D161');
        $sheet->setCellValue('C161','日量');
        $sheet->mergeCells('E161:F161');
        $sheet->setCellValue('E161','月累积量');
        $sheet->mergeCells('G161:H161');
        $sheet->setCellValue('G161','日量');
        $sheet->mergeCells('I161:J161');
        $sheet->setCellValue('I161','月累积量');
        $sheet->mergeCells('K161:L161');
        $sheet->setCellValue('K161','日量');
        $sheet->mergeCells('M161:N161');
        $sheet->setCellValue('M161','月累积量');
        $sheet->mergeCells('A162:B163');
        $sheet->setCellValue('A162',$info['cbjcs']);
        $sheet->mergeCells('C162:D163');
        $sheet->setCellValue('C162',$info['cbjclr']);
        $sheet->mergeCells('E162:F163');
        $sheet->setCellValue('E162',$info['cbjcly']);
        $sheet->mergeCells('G162:H163');
        $sheet->setCellValue('G162',$info['cbjglr']);
        $sheet->mergeCells('I162:J163');
        $sheet->setCellValue('I162',$info['cbjgly']);
        $sheet->mergeCells('K162:L163');
        $sheet->setCellValue('K162',$info['cbsclr']);
        $sheet->mergeCells('M162:N163');
        $sheet->setCellValue('M162',$info['cbscly']);
        $sheet->mergeCells('O162:P163');
        $sheet->setCellValue('O162',$info['sbsl']);
        $sheet->mergeCells('Q162:R163');
        $sheet->setCellValue('Q162',$info['cbsl']);

        $sheet->mergeCells('A164:B166');
        $sheet->setCellValue('A164','粗苯储量（t）');
        $sheet->mergeCells('C164:D164');
        $sheet->setCellValue('C164','1#罐');
        $sheet->mergeCells('E164:F164');
        $sheet->setCellValue('E164','2#罐');
        $sheet->mergeCells('G164:H164');
        $sheet->setCellValue('G164','3#罐');
        $sheet->mergeCells('I164:J166');
        $sheet->setCellValue('I164','纯苯储量（t）');
        $sheet->mergeCells('K164:L164');
        $sheet->setCellValue('K164','5#罐');
        $sheet->mergeCells('M164:N164');
        $sheet->setCellValue('M164','6#罐');
        $sheet->mergeCells('O164:R164');
        $sheet->setCellValue('O164','耗驰放气量（万m³）');
        $sheet->mergeCells('O165:P165');
        $sheet->setCellValue('O165','日量');
        $sheet->mergeCells('Q165:R165');
        $sheet->setCellValue('Q165','月累积量');
        $sheet->mergeCells('C165:D166');
        $sheet->setCellValue('C165',$info['cbcl1']);
        $sheet->mergeCells('E165:F166');
        $sheet->setCellValue('E165',$info['cbcl2']);
        $sheet->mergeCells('G165:H166');
        $sheet->setCellValue('G165',$info['cbcl3']);
        $sheet->mergeCells('K165:L166');
        $sheet->setCellValue('K165',$info['cbcl5']);
        $sheet->mergeCells('M165:N166');
        $sheet->setCellValue('M165',$info['cbcl6']);
        $sheet->mergeCells('O166:P167');
        $sheet->setCellValue('O166',$info['hcfqlr']);
        $sheet->mergeCells('Q166:R167');
        $sheet->setCellValue('Q166',$info['hcfqly']);
        $sheet->mergeCells('A167:B167');
        $sheet->setCellValue('A167','粗苯合计储量（t）');
        $sheet->mergeCells('C167:H167');
        $sheet->setCellValue('C167',sprintf("%01.2f", ($info['cbcl1']+$info['cbcl2']+$info['cbcl3'])));
        $sheet->mergeCells('I167:J167');
        $sheet->setCellValue('I167','纯苯合计储量（t）');
        $sheet->mergeCells('K167:N167');
        $sheet->setCellValue('K167',sprintf("%01.2f", ($info['cbcl5']+$info['cbcl6'])));

        $sheet->mergeCells('A168:A171');
        $sheet->setCellValue('A168','纯度分析（%）');
        $sheet->mergeCells('B168:C168');
        $sheet->setCellValue('B168','分析装置区');
        $sheet->mergeCells('B169:C169');
        $sheet->setCellValue('B169','装置区一期');
        $sheet->mergeCells('B170:C170');
        $sheet->setCellValue('B170','装置区二期');
        $sheet->mergeCells('B171:C171');
        $sheet->setCellValue('B171','装置区三期');
        $sheet->mergeCells('A172:C173');
        $sheet->setCellValue('A172','其他产品液位');
        $sheet->mergeCells('A174:C174');
        $sheet->setCellValue('A174','其它产品产量(t)');
        $sheet->mergeCells('D168:E168');
        $sheet->setCellValue('D168','纯苯');
        $sheet->mergeCells('D169:E169');
        $sheet->setCellValue('D169',$info['cb1']);
        $sheet->mergeCells('D170:E170');
        $sheet->setCellValue('D170',$info['cb2']);
        $sheet->mergeCells('D171:E171');
        $sheet->setCellValue('D171',$info['cb3']);
        $sheet->mergeCells('F168:G168');
        $sheet->setCellValue('F168','甲苯');
        $sheet->mergeCells('F169:G169');
        $sheet->setCellValue('F169',$info['jb1']);
        $sheet->mergeCells('F170:G170');
        $sheet->setCellValue('F170',$info['jb2']);
        $sheet->mergeCells('F171:G171');
        $sheet->setCellValue('F171',$info['jb3']);
        $sheet->mergeCells('H168:I168');
        $sheet->setCellValue('H168','甲基环己烷');
        $sheet->mergeCells('H169:I169');
        $sheet->setCellValue('H169',$info['jjhyw1']);
        $sheet->mergeCells('H170:I170');
        $sheet->setCellValue('H170',$info['jjhyw2']);
        $sheet->mergeCells('H171:I171');
        $sheet->setCellValue('H171',$info['jjhyw3']);
        $sheet->mergeCells('J168:K168');
        $sheet->setCellValue('J168','总环戊烷');
        $sheet->mergeCells('J169:K169');
        $sheet->setCellValue('J169',$info['zff1']);
        $sheet->mergeCells('J170:K170');
        $sheet->setCellValue('J170',$info['zff2']);
        $sheet->mergeCells('J171:K171');
        $sheet->setCellValue('J171',$info['zff3']);
        $sheet->mergeCells('L168:M168');
        $sheet->setCellValue('L168','总硫');
        $sheet->mergeCells('L169:M169');
        $sheet->setCellValue('L169',$info['zl1']);
        $sheet->mergeCells('L170:M170');
        $sheet->setCellValue('L170',$info['zl2']);
        $sheet->mergeCells('L171:M171');
        $sheet->setCellValue('L171',$info['zl3']);
        $sheet->mergeCells('N168:O168');
        $sheet->setCellValue('N168','噻吩');
        $sheet->mergeCells('N169:O169');
        $sheet->setCellValue('N169',$info['sf1']);
        $sheet->mergeCells('N170:O170');
        $sheet->setCellValue('N170',$info['sf2']);
        $sheet->mergeCells('N171:O171');
        $sheet->setCellValue('N171',$info['sf3']);
        $sheet->mergeCells('P168:Q168');
        $sheet->setCellValue('P168','含水');
        $sheet->mergeCells('P169:Q169');
        $sheet->setCellValue('P169',$info['hs1']);
        $sheet->mergeCells('P170:Q170');
        $sheet->setCellValue('P170',$info['hs2']);
        $sheet->mergeCells('P171:Q171');
        $sheet->setCellValue('P171',$info['hs3']);
        $sheet->mergeCells('R168:S168');
        $sheet->setCellValue('R168','环戊烷含苯');
        $sheet->mergeCells('R169:S169');
        $sheet->setCellValue('R169',$info['ffhb1']);
        $sheet->mergeCells('R170:S170');
        $sheet->setCellValue('R170',$info['ffhb2']);
        $sheet->mergeCells('R171:S171');
        $sheet->setCellValue('R171',$info['ffhb3']);
        $sheet->mergeCells('T168:V168');
        $sheet->setCellValue('T168','重苯含二甲');
        $sheet->mergeCells('T169:V169');
        $sheet->setCellValue('T169',$info['zbhej1']);
        $sheet->mergeCells('T170:V170');
        $sheet->setCellValue('T170',$info['zbhej2']);
        $sheet->mergeCells('T171:V171');
        $sheet->setCellValue('T171',$info['zbhej3']);

        $sheet->mergeCells('D172:E172');
        $sheet->setCellValue('D172','甲苯(7# 8#)');
        $sheet->mergeCells('F172:G172');
        $sheet->setCellValue('F172','二甲苯9#');
        $sheet->mergeCells('H172:I172');
        $sheet->setCellValue('H172','重苯(13#)');
        $sheet->mergeCells('J172:K172');
        $sheet->setCellValue('J172','环戊烷（12#）');
        $sheet->mergeCells('L172:M172');
        $sheet->setCellValue('L172','C8+（10#）');
        $sheet->mergeCells('N172:V174');
        $sheet->setCellValue('N172',$info['hzq']);
        $sheet->setCellValue('D173',$info['jb7']);
        $sheet->setCellValue('E173',$info['jb8']);
        $sheet->mergeCells('F173:G173');
        $sheet->setCellValue('F173',$info['ejb9']);
        $sheet->mergeCells('H173:I173');
        $sheet->setCellValue('H173',$info['zb13']);
        $sheet->mergeCells('J173:K173');
        $sheet->setCellValue('J173',$info['ffj12']);
        $sheet->mergeCells('L173:M173');
        $sheet->setCellValue('L173',$info['c8']);

        $sheet->mergeCells('D174:E174');
        $sheet->setCellValue('D174',$info['qita78']);
        $sheet->mergeCells('F174:G174');
        $sheet->setCellValue('F174',$info['qita9']);
        $sheet->mergeCells('H174:I174');
        $sheet->setCellValue('H174',$info['qita13']);
        $sheet->mergeCells('J174:K174');
        $sheet->setCellValue('J174',$info['qita12']);
        $sheet->mergeCells('L174:M174');
        $sheet->setCellValue('L174',$info['qita10']);

        $sheet->mergeCells('A175:V175');

        return $sheet;
    }
    
    //园区介质互通情况 报表
    public function yqjzhtqk($sheet,$where){
        $info = Db::name('yqjzhtqk')->where($where)->find();
        if(empty($info)){
            $this->errorMsg = '园区介质互通情况中没有找到已审核数据';
            return $sheet;
        }
        $sheet->mergeCells('A176:V176');
        $sheet->setCellValue('A176','园区介质互通情况');
        $sheet->getStyle('A176')->getFont()->setSize(18);
        $sheet->getStyle('A176:V188')->getFont()->setBold(true);
        $sheet->getStyle('A176')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A177:R178')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A181:R182')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A185:R186')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');

        
        $sheet->mergeCells('A177:B184');
        $sheet->setCellValue('A177','中浩公司互通');
        $sheet->mergeCells('C177:F177');
        $sheet->setCellValue('C177','纯苯（t）');
        $sheet->mergeCells('G177:J177');
        $sheet->setCellValue('G177','甲醇（t）');
        $sheet->mergeCells('K177:N177');
        $sheet->setCellValue('K177','氮气（万m³）');
        $sheet->mergeCells('O177:R177');
        $sheet->setCellValue('O177','驰放气（万m³）');

        $sheet->mergeCells('C178:D178');
        $sheet->setCellValue('C178','日量');
        $sheet->mergeCells('E178:F178');
        $sheet->setCellValue('E178','月累积量');
        $sheet->mergeCells('G178:H178');
        $sheet->setCellValue('G178','日量');
        $sheet->mergeCells('I178:J178');
        $sheet->setCellValue('I178','月累积量');
        $sheet->mergeCells('K178:L178');
        $sheet->setCellValue('K178','日量');
        $sheet->mergeCells('M178:N178');
        $sheet->setCellValue('M178','月累积量');
        $sheet->mergeCells('O178:P178');
        $sheet->setCellValue('O178','日量');
        $sheet->mergeCells('Q178:R178');
        $sheet->setCellValue('Q178','月累积量');
        
        $sheet->mergeCells('C179:D180');
        $sheet->setCellValue('C179',$info['cbr']);
        $sheet->mergeCells('E179:F180');
        $sheet->setCellValue('E179',$info['cby']);
        $sheet->mergeCells('G179:H180');
        $sheet->setCellValue('G179',$info['jcr']);
        $sheet->mergeCells('I179:J180');
        $sheet->setCellValue('I179',$info['jcy']);
        $sheet->mergeCells('K179:L180');
        $sheet->setCellValue('K179',$info['dqr']);
        $sheet->mergeCells('M179:N180');
        $sheet->setCellValue('M179',$info['dqy']);
        $sheet->mergeCells('O179:P180');
        $sheet->setCellValue('O179',$info['cfqr']);
        $sheet->mergeCells('Q179:R180');
        $sheet->setCellValue('Q179',$info['cfqy']);
        
        $sheet->mergeCells('S177:V184');
        $sheet->setCellValue('S177',$info['content1']);
        $styleArray2 = [
            'alignment' => [
                'horizontal' => Alignment::HORIZONTAL_LEFT,
                'vertical'=>Alignment::VERTICAL_TOP
            ],
        ];
        $sheet->getStyle('S177')->applyFromArray($styleArray2);
        
        $sheet->mergeCells('C181:F181');
        $sheet->setCellValue('C181','解析气（万m³）');
        $sheet->mergeCells('G181:J181');
        $sheet->setCellValue('G181','污水（t）');
        $sheet->mergeCells('K181:N181');
        $sheet->setCellValue('K181','蒸汽（中浩供）（t）');
        $sheet->mergeCells('O181:R181');
        $sheet->setCellValue('O181','蒸汽（中润供）（t）');
        $sheet->mergeCells('C182:D182');
        $sheet->setCellValue('C182','日量');
        $sheet->mergeCells('E182:F182');
        $sheet->setCellValue('E182','月累积量');
        $sheet->mergeCells('G182:H182');
        $sheet->setCellValue('G182','日量');
        $sheet->mergeCells('I182:J182');
        $sheet->setCellValue('I182','月累积量');
        $sheet->mergeCells('K182:L182');
        $sheet->setCellValue('K182','日量');
        $sheet->mergeCells('M182:N182');
        $sheet->setCellValue('M182','月累积量');
        $sheet->mergeCells('O182:P182');
        $sheet->setCellValue('O182','日量');
        $sheet->mergeCells('Q182:R182');
        $sheet->setCellValue('Q182','月累积量');
        $sheet->mergeCells('C183:D184');
        $sheet->setCellValue('C183',$info['jxqr']);
        $sheet->mergeCells('E183:F184');
        $sheet->setCellValue('E183',$info['jxqy']);
        $sheet->mergeCells('G183:H184');
        $sheet->setCellValue('G183',$info['wsr']);
        $sheet->mergeCells('I183:J184');
        $sheet->setCellValue('I183',$info['wsy']);
        $sheet->mergeCells('K183:L184');
        $sheet->setCellValue('K183',$info['zqzhr']);
        $sheet->mergeCells('M183:N184');
        $sheet->setCellValue('M183',$info['zqzhy']);
        $sheet->mergeCells('O183:P184');
        $sheet->setCellValue('O183',$info['zqzr1r']);
        $sheet->mergeCells('Q183:R184');
        $sheet->setCellValue('Q183',$info['zqzr1y']);

        $sheet->mergeCells('A185:B188');
        $sheet->setCellValue('A185','炭素公司互通');
        $sheet->mergeCells('C185:F185');
        $sheet->setCellValue('C185','焦炉煤气（万m³）');
        $sheet->mergeCells('G185:J185');
        $sheet->setCellValue('G185','蒸汽（中润供）（t）');
        $sheet->mergeCells('K185:N185');
        $sheet->setCellValue('K185','焦油（t）186t/m');
        $sheet->mergeCells('O185:R185');
        $sheet->setCellValue('O185','博泰蒸汽(中润供)(t)');
        $sheet->mergeCells('C186:D186');
        $sheet->setCellValue('C186','日量');
        $sheet->mergeCells('E186:F186');
        $sheet->setCellValue('E186','月累积量');
        $sheet->mergeCells('G186:H186');
        $sheet->setCellValue('G186','日量');
        $sheet->mergeCells('I186:J186');
        $sheet->setCellValue('I186','月累积量');
        $sheet->mergeCells('K186:L186');
        $sheet->setCellValue('K186','日量');
        $sheet->mergeCells('M186:N186');
        $sheet->setCellValue('M186','月累积量');
        $sheet->mergeCells('O186:P186');
        $sheet->setCellValue('O186','日量');
        $sheet->mergeCells('Q186:R186');
        $sheet->setCellValue('Q186','月累积量');
        $sheet->mergeCells('C187:D188');
        $sheet->setCellValue('C187',$info['jrmqr']);
        $sheet->mergeCells('E187:F188');
        $sheet->setCellValue('E187',$info['jrmqy']);
        $sheet->mergeCells('G187:H188');
        $sheet->setCellValue('G187',$info['zqzr2r']);
        $sheet->mergeCells('I187:J188');
        $sheet->setCellValue('I187',$info['zqzr2y']);
        $sheet->mergeCells('K187:L188');
        $sheet->setCellValue('K187',$info['jyr']);
        $sheet->mergeCells('M187:N188');
        $sheet->setCellValue('M187',$info['jyy']);
        $sheet->mergeCells('O187:P188');
        $sheet->setCellValue('O187',$info['btzqr']);
        $sheet->mergeCells('Q187:R188');
        $sheet->setCellValue('Q187',$info['btzqy']);

        $sheet->mergeCells('S185:V188');
        $sheet->setCellValue('S185',$info['content2']);
        $styleArray2 = [
            'alignment' => [
                'horizontal' => Alignment::HORIZONTAL_LEFT,
                'vertical'=>Alignment::VERTICAL_TOP
            ],
        ];
        $sheet->getStyle('S185')->applyFromArray($styleArray2);

        $sheet->mergeCells('A189:V189');

        return $sheet;
    }
    
    //水质指标分析 报表
    public function hbzb($sheet,$where){
        $info = Db::name('hbzb')->where($where)->find();
        if(empty($info)){
            $this->errorMsg = '水质指标分析中没有找到已审核数据';
            return $sheet;
        }
        $sheet->mergeCells('A190:V190');
        $sheet->setCellValue('A190','水质指标分析');
        $sheet->getStyle('A190')->getFont()->setSize(18);
        $sheet->getStyle('A190:V207')->getFont()->setBold(true);
        $sheet->getStyle('A190')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A191:S192')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('E199:V200')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A199:B202')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('A203:V204')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');
        $sheet->getStyle('Q205:V206')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');

        $sheet->mergeCells('A191:B198');
        $sheet->setCellValue('A191','净化排水');
        $sheet->mergeCells('C191:D192');
        $sheet->setCellValue('C191','污水处理');
        $sheet->mergeCells('E191:F191');
        $sheet->setCellValue('E191','PH');
        $sheet->mergeCells('E192:F192');
        $sheet->setCellValue('E192','6-9');
        $sheet->mergeCells('G191:H191');
        $sheet->setCellValue('G191','COD');
        $sheet->mergeCells('I191:J191');
        $sheet->setCellValue('I191','氨氮');
        $sheet->mergeCells('K191:L191');
        $sheet->setCellValue('K191','总磷');
        $sheet->mergeCells('M191:N191');
        $sheet->setCellValue('M191','总氮');
        $sheet->mergeCells('G192:N192');
        $sheet->setCellValue('G192','（mg/L）');
        $sheet->mergeCells('O191:S192');
        $sheet->setCellValue('O191','排放口国控指标');
        $sheet->mergeCells('T191:V198');
        $sheet->setCellValue('T191',$info['content1']);
        $styleArray2 = [
            'alignment' => [
                'horizontal' => Alignment::HORIZONTAL_LEFT,
                'vertical'=>Alignment::VERTICAL_TOP
            ],
        ];
        $sheet->getStyle('T191')->applyFromArray($styleArray2);

        $sheet->mergeCells('C193:D194');
        $sheet->setCellValue('C193','新生化');
        $sheet->mergeCells('E193:F194');
        $sheet->setCellValue('E193',$info['phxs']);
        $sheet->mergeCells('G193:H194');
        $sheet->setCellValue('G193',$info['codxs']);
        $sheet->mergeCells('I193:J194');
        $sheet->setCellValue('I193',$info['adxs']);
        $sheet->mergeCells('K193:L194');
        $sheet->setCellValue('K193',$info['zlxs']);
        $sheet->mergeCells('M193:N194');
        $sheet->setCellValue('M193',$info['zdxs']);
        $sheet->mergeCells('O193:S194');
        $sheet->setCellValue('O193','COD：500 氨氮：45 总磷：10 总氮：350');
        $sheet->mergeCells('C195:D196');
        $sheet->setCellValue('C195','老生化');
        $sheet->mergeCells('E195:F196');
        $sheet->setCellValue('E195',$info['phls']);
        $sheet->mergeCells('G195:H196');
        $sheet->setCellValue('G195',$info['codls']);
        $sheet->mergeCells('I195:J196');
        $sheet->setCellValue('I195',$info['adls']);
        $sheet->mergeCells('K195:L196');
        $sheet->setCellValue('K195',$info['zlls']);
        $sheet->mergeCells('M195:N196');
        $sheet->setCellValue('M195',$info['zdls']);
        $sheet->mergeCells('O195:S196');
        $sheet->setCellValue('O195','COD：150 氨氮：25 总磷：3 总氮：50');
        $sheet->mergeCells('C197:D198');
        $sheet->setCellValue('C197','深度处理');
        $sheet->mergeCells('E197:F198');
        $sheet->setCellValue('E197','—');
        $sheet->mergeCells('G197:H198');
        $sheet->setCellValue('G197','—');
        $sheet->mergeCells('I197:J198');
        $sheet->setCellValue('I197','—');
        $sheet->mergeCells('K197:L198');
        $sheet->setCellValue('K197','—');
        $sheet->mergeCells('M197:N198');
        $sheet->setCellValue('M197','—');
        $sheet->mergeCells('O197:S198');
        $sheet->setCellValue('O197','—');
        $sheet->mergeCells('A199:B202');
        $sheet->setCellValue('A199','动力雨水');
        $sheet->mergeCells('C199:D202');
        $sheet->setCellValue('C199','雨水总排口');
        $sheet->mergeCells('E199:F199');
        $sheet->setCellValue('E199','酚');
        $sheet->mergeCells('G199:H199');
        $sheet->setCellValue('G199','悬浮物');
        $sheet->mergeCells('I199:J199');
        $sheet->setCellValue('I199','氨氮');
        $sheet->mergeCells('K199:L199');
        $sheet->setCellValue('K199','COD');
        $sheet->mergeCells('M199:N199');
        $sheet->setCellValue('M199','Cl-');
        $sheet->mergeCells('O199:V199');
        $sheet->setCellValue('O199','雨水总排口国控指标');
        $sheet->mergeCells('E200:N200');
        $sheet->setCellValue('E200','（mg/L）');
        $sheet->mergeCells('O200:V200');
        $sheet->setCellValue('O200','（mg/L）');
        $sheet->mergeCells('E201:F202');
        $sheet->setCellValue('E201',$info['ysfen']);
        $sheet->mergeCells('G201:H202');
        $sheet->setCellValue('G201',$info['ysxfw']);
        $sheet->mergeCells('I201:J202');
        $sheet->setCellValue('I201',$info['ysad']);
        $sheet->mergeCells('K201:L202');
        $sheet->setCellValue('K201',$info['yscod']);
        $sheet->mergeCells('M201:N202');
        $sheet->setCellValue('M201',$info['yscl']);
        $sheet->mergeCells('O201:V202');
        $sheet->setCellValue('O201','COD：50 氨氮：5.0 悬浮物：10 总氮：15');

        $sheet->mergeCells('A203:B206');
        $sheet->setCellValue('A203','水源水指标');
        $sheet->mergeCells('C203:D204');
        $sheet->mergeCells('E203:F203');
        $sheet->setCellValue('E203','PH');
        $sheet->mergeCells('G203:H203');
        $sheet->setCellValue('G203','硬度');
        $sheet->mergeCells('I203:J203');
        $sheet->setCellValue('I203','碱度');
        $sheet->mergeCells('K203:L203');
        $sheet->setCellValue('K203','浊度');
        $sheet->mergeCells('M203:N203');
        $sheet->setCellValue('M203','Cl-');
        $sheet->mergeCells('O203:P203');
        $sheet->setCellValue('O203','电导率');
        $sheet->mergeCells('E204:F204');
        $sheet->setCellValue('E204','6.5-8.5');
        $sheet->mergeCells('G204:N204');
        $sheet->setCellValue('G204','（mg/L）');
        $sheet->mergeCells('O204:P204');
        $sheet->setCellValue('O204','μs/cm');
        $sheet->mergeCells('Q203:V204');
        $sheet->setCellValue('Q203','进厂水源水参考指标');
        $sheet->mergeCells('Q205:V206');
        $sheet->setCellValue('Q205','硬度：450 碱度：350 浊度：3 Cl-：250');
        $sheet->mergeCells('C205:D205');
        $sheet->setCellValue('C205','一二期');
        $sheet->mergeCells('C206:D206');
        $sheet->setCellValue('C206','三期');

        $sheet->mergeCells('E205:F205');
        $sheet->setCellValue('E205',$info['syph1']);
        $sheet->mergeCells('G205:H205');
        $sheet->setCellValue('G205',$info['syyd1']);
        $sheet->mergeCells('I205:J205');
        $sheet->setCellValue('I205',$info['syjd1']);
        $sheet->mergeCells('K205:L205');
        $sheet->setCellValue('K205',$info['syzd1']);
        $sheet->mergeCells('M205:N205');
        $sheet->setCellValue('M205',$info['sycl1']);
        $sheet->mergeCells('O205:P205');
        $sheet->setCellValue('O205',$info['syddl1']);
        
        $sheet->mergeCells('E206:F206');
        $sheet->setCellValue('E206',$info['syph2']);
        $sheet->mergeCells('G206:H206');
        $sheet->setCellValue('G206',$info['syyd2']);
        $sheet->mergeCells('I206:J206');
        $sheet->setCellValue('I206',$info['syjd2']);
        $sheet->mergeCells('K206:L206');
        $sheet->setCellValue('K206',$info['syzd2']);
        $sheet->mergeCells('M206:N206');
        $sheet->setCellValue('M206',$info['sycl2']);
        $sheet->mergeCells('O206:P206');
        $sheet->setCellValue('O206',$info['syddl2']);

        $sheet->mergeCells('A207:V207');
        $sheet->setCellValue('A207',$info['content2']);
        $styleArray2 = [
            'alignment' => [
                'horizontal' => Alignment::HORIZONTAL_LEFT,
                'vertical'=>Alignment::VERTICAL_TOP
            ],
        ];
        $sheet->getStyle('A207')->applyFromArray($styleArray2);

        return $sheet;
    }
    
    //日生产分析 报表
    public function rscfx($sheet,$where){
        $rscfxData = Db::name('rscfx')->where($where)->select()->toArray();
        if(empty($rscfxData)){
            $this->errorMsg = '日生产分析中没有找到已审核数据';
            return $sheet;
        }
        $sheet->mergeCells('A208:V208');
        $sheet->setCellValue('A208','日生产分析');
        $sheet->getStyle('A208')->getFont()->setSize(18);
        $sheet->getStyle('A208:V309')->getFont()->setBold(true);
        $sheet->getStyle('A208')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');

        $sheet->mergeCells('A209:V309');
        $sheet->getStyle('A209:V309')->getFont()->setSize(22);

        $content = '';
        $arr = ['一','二','三','四','五','六','七','八','九','十'];
        $a = 0;
        foreach ($rscfxData as $key => $value) {
            if(!empty($value['title'])||!empty($value['content'])){
                $content .= $arr[$a].'、';
                $content .= $value['label'].':';
                $content .= $value['title'];
                $content .= "\r\n";
                $content .= "重要检修：\r\n";
                $content .= $value['content'];
                $content .= "\r\n\r\n";
                $a++;
            }
        }
        
        $sheet->setCellValue('A209',$content);
        $styleArray2 = [
            'alignment' => [
                'horizontal' => Alignment::HORIZONTAL_LEFT,
                'vertical'=>Alignment::VERTICAL_TOP
            ],
        ];
        $sheet->getStyle('A209')->applyFromArray($styleArray2);

        return $sheet;
    }

    
    //日工程分析 报表
    public function rgcfx($sheet,$where){
        $rgcfxData = Db::name('rgcfx')->where($where)->select()->toArray();
        if(empty($rgcfxData)){
            $this->errorMsg = '日工程分析中没有找到已审核数据';
            return $sheet;
        }
        $sheet->mergeCells('A310:V310');
        $sheet->setCellValue('A310','日工程分析');
        $sheet->getStyle('A310')->getFont()->setSize(18);
        $sheet->getStyle('A310:V390')->getFont()->setBold(true);
        $sheet->getStyle('A310')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('CCCCCC');

        $sheet->mergeCells('A311:V390');
        $sheet->getStyle('A311:V390')->getFont()->setSize(22);

        $content = '';
        $arr = ['一','二','三','四','五','六','七','八','九','十'];
        foreach ($rgcfxData as $key => $value) {
            if(!empty($value['content'])){
                $content .= $arr[$key].'、';
                $content .= $value['label'].':';
                $content .= "\r\n";
                $content .= $value['content'];
                $content .= "\r\n\r\n";
            }
        }
        
        $sheet->setCellValue('A311',$content);
        $styleArray2 = [
            'alignment' => [
                'horizontal' => Alignment::HORIZONTAL_LEFT,
                'vertical'=>Alignment::VERTICAL_TOP
            ],
        ];
        $sheet->getStyle('A311')->applyFromArray($styleArray2);

        return $sheet;
    }

    /**
     * @notes excel库存数据导出
     * @return \think\response\Json
     * @author zw
     * @date 2023/2/1 13:24
     */
    public function exportExcelStock(){
        $data = input('param.');
        $date = !empty($data['date'])?$data['date']:date('Y-m-d',strtotime('-1 day'));
        $where = [
            "date"=>$date,
            "status"=>2
        ];
        
        $spreadsheet = new Spreadsheet();
        // 创建sheet
        $sheet = $spreadsheet->getActiveSheet();
        // 全局样式
        $spreadsheet->getDefaultStyle()->getFont()->setName('宋体'); // 字体
        $spreadsheet->getDefaultStyle()->getFont()->setSize(12); // 字体大小
        $zmarr = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O'];
        foreach ($zmarr as $value) {
            $spreadsheet->getActiveSheet()->getColumnDimension($value)->setWidth(10);
        }
        $spreadsheet->getActiveSheet()->getColumnDimension('A')->setWidth(16);
        $spreadsheet->getActiveSheet()->getColumnDimension('B')->setWidth(16);
        $spreadsheet->getActiveSheet()->getColumnDimension('D')->setWidth(16);
        $spreadsheet->getActiveSheet()->getColumnDimension('K')->setWidth(16);
        $spreadsheet->getActiveSheet()->getColumnDimension('L')->setWidth(16);
        $spreadsheet->getActiveSheet()->getColumnDimension('N')->setWidth(24);
        $spreadsheet->getActiveSheet()->getColumnDimension('O')->setWidth(24);
        //默认水平居中
        $spreadsheet->getDefaultStyle()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
        //默认垂直居中
        $spreadsheet->getDefaultStyle()->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
        // 自动换行
        $spreadsheet->getDefaultStyle()->getAlignment()->setWrapText(true);

        $border = [
            'borders' => [
                'outline' => [//外边框
                    'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
                ],
                'inside' =>[ //内边框
                    'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
                ]
            ],
         ];
        $spreadsheet->getActiveSheet(1)->getStyle('A1:L49')->applyFromArray($border);

        // 开始编写表格
        // 第一行
        $sheet->mergeCells('A1:L1');
        $sheet->setCellValue('A1','各分厂药剂库存统计表');
        $sheet->getCell('A1')->getStyle()->getFont()->setSize(22);
        $sheet->getStyle('A1:L2')->getFont()->setBold(true);

        $sheet->setCellValue('A2','材料名称');
        $sheet->setCellValue('B2','包装、规格');
        $sheet->setCellValue('C2','储存形式');
        $sheet->setCellValue('D2','库存上下限');
        $sheet->setCellValue('E2','库存');
        $sheet->setCellValue('F2','当日用量');
        $sheet->setCellValue('G2','计量单位');
        // $sheet->setCellValue('H2','控制指标');
        // $sheet->setCellValue('I2','当日指标');
        // $sheet->setCellValue('J2','计量单位');
        $sheet->setCellValue('H2','所属单位');
        $sheet->setCellValue('I2','库存可用天数');
        $sheet->setCellValue('J2','备注');
        $sheet->getComment('J2')->getText()->createTextRun('（①库存超限原因；②当日用量超量原因）');
        $sheet->setCellValue('K2','使用地点');
        $sheet->setCellValue('L2','作用');
         
        $sheet->mergeCells('A4:A6');
        $sheet->mergeCells('A8:A9');
        $sheet->mergeCells('A10:A12');
        $sheet->mergeCells('A13:A15');
        $sheet->mergeCells('A19:A20');
        $sheet->mergeCells('A21:A22');
        $sheet->mergeCells('A23:A24');
        $sheet->mergeCells('A25:A26');
        $sheet->mergeCells('A45:A46');

        $stockData = Db::name('stock')->where($where)->select()->toArray();
        if(empty($stockData)){
            return $this->fail($date.'库存统计表中未找到已审核数据');
        }
        $a = 3;
        foreach ($stockData as $key => $value) {
            $sheet->setCellValue('A'.$a,$value['name']);
            $sheet->setCellValue('B'.$a,$value['percentage']);
            $sheet->setCellValue('C'.$a,$value['mode']);
            $sheet->setCellValue('D'.$a,$value['limit']);
            $sheet->setCellValue('E'.$a,$value['kc']);
            $sheet->setCellValue('F'.$a,$value['dryl']);
            $sheet->setCellValue('G'.$a,$value['unit1']);
            $sheet->setCellValue('H'.$a,$value['company']);
            $sheet->setCellValue('I'.$a,$value['kckyts']);
            $sheet->setCellValue('J'.$a,$value['bz']);
            $sheet->setCellValue('K'.$a,$value['place']);
            $sheet->setCellValue('L'.$a,$value['effect']);
            $a++;
        }

        // 设置下载与后缀
        header("Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        ob_end_clean();//清楚缓存区
        $filename = $date.'各分厂药剂库存统计表';
        // 激活浏览器窗口
        header("Content-Disposition:attachment;filename=$filename.xlsx");
        //缓存控制
        header("Cache-Control:max-age=0");
        // 调用方法执行下载
        $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
        //创建excel文件
        $exportCache = new ExportCache();
        $src = $exportCache->getSrc();

        if (!file_exists($src)) {
            mkdir($src, 0775, true);
        }
        $writer->save($src . $filename.'.xlsx');
        //设置本地excel缓存并返回下载地址
        $vars = ['file' => $exportCache->setFile($filename.'.xlsx')];
        return $this->success('', ['path'=>(string)(url('adminapi/download/export', $vars, true, true))], 1, 1);
    }
    
}